└── JavaList /JavaList: -------------------------------------------------------------------------------- 1 | import java.io.*; 2 | import java.util.*; 3 | import java.text.*; 4 | import java.math.*; 5 | import java.util.regex.*; 6 | public class JavaList { 7 | public static void main(String[] args) { 8 | Scanner scanner = new Scanner(System.in); 9 | int N = scanner.nextInt(); 10 | List L = new ArrayList(N); 11 | for (int i = 0; i < N; i++) 12 | { 13 | L.add(scanner.nextInt()); 14 | } 15 | int Q = scanner.nextInt(); 16 | for (int i = 0; i < Q; i++) 17 | { 18 | String operation = scanner.next(); 19 | if (operation.equals("Insert")) 20 | { 21 | int index = scanner.nextInt(); 22 | int value = scanner.nextInt(); 23 | L.add(index, value); 24 | } 25 | else if (operation.equals("Delete")) 26 | { 27 | int index = scanner.nextInt(); 28 | L.remove(index); 29 | } 30 | } 31 | for (int element: L) 32 | { 33 | System.out.print(element + " "); 34 | } 35 | } 36 | } 37 | --------------------------------------------------------------------------------