forked from Bhavya1912/Hackerrank-1
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJavaArraylist.java
More file actions
30 lines (28 loc) · 822 Bytes
/
JavaArraylist.java
File metadata and controls
30 lines (28 loc) · 822 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
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
public class Solution {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int t=sc.nextInt();
ArrayList<ArrayList<Integer>> a = new ArrayList<ArrayList<Integer>>();
while(t-->0){
ArrayList<Integer> b = new ArrayList<Integer>();
int n= sc.nextInt();
while(n-->0)
b.add(sc.nextInt());
a.add(b);
}
int q=sc.nextInt();
while(q-->0){
int x=sc.nextInt();
int y=sc.nextInt();
if(y>a.get(x-1).size())
System.out.println("ERROR!");
else
System.out.println(a.get(x-1).get(y-1));
}
}
}