-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathArrayList.java
More file actions
43 lines (35 loc) · 781 Bytes
/
ArrayList.java
File metadata and controls
43 lines (35 loc) · 781 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
34
35
36
37
38
39
40
41
42
43
/*
https://www.hackerrank.com/challenges/java-arraylist
*/
import java.util.*;
public class Main{
public static Scanner input = new Scanner(System.in);
public static void main(String[] args) {
int n = input.nextInt();
ArrayList<Integer>[] lists = new ArrayList[n];
for(int i=0;i<n;i++)
lists[i] = new ArrayList<Integer>();
for(int i=0;i<n;i++){
int m = input.nextInt();
for(int j=0;j<m;j++){
int a = input.nextInt();
lists[i].add(a);
}
}
int q = input.nextInt();
int x,y;
for(int i=0;i<q;i++){
x = input.nextInt();
y = input.nextInt();
x--;y--;
if(x<n){
if(y<lists[x].size())
System.out.println(lists[x].get(y));
else
System.out.println("ERROR!");
}
else
System.out.println("ERROR!");
}
}
}