-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathJavaArraylist.java
More file actions
33 lines (29 loc) · 967 Bytes
/
JavaArraylist.java
File metadata and controls
33 lines (29 loc) · 967 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package DataStructure;
import java.util.*;
public class JavaArraylist {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int count = scan.nextInt(), query, number;
List<List<Integer>> numbers = new ArrayList<>();
for (int x = 0; x < count; x++) {
numbers.add(new ArrayList<>());
query = scan.nextInt();
for (int y = 0; y < query; y++) {
number = scan.nextInt();
numbers.get(x).add(number);
}
}
count = scan.nextInt();
List<Integer> tmp;
for (int x = 0; x < count; x++) {
query = scan.nextInt();
number = scan.nextInt();
tmp = numbers.get(query - 1);
if (tmp.size() > number - 1) {
System.out.println(tmp.get(number - 1));
} else {
System.out.println("ERROR!");
}
}
}
}