I have some trouble submitting my code. It works perfectly fine when I hit the run button but prompts me an error after submitting it. Please help me out on this one.
Contest Code : IARCSJUD | Problem Code : BOOKLIST
import java.util.*;
import java.lang.*;
import java.io.*;
class Codechef
{
static Scanner sc = new Scanner(System.in);
static ArrayList<String> books;
static int r, t, temp;
static Map<Integer, String> map = new HashMap<>();
static void input(int n) {
sc.nextLine();
r = n;
register();
}
static void register() {
//System.out.println("Enter the books : ");
books = new ArrayList<String> (Arrays.asList(sc.nextLine().split(" ")));
//System.out.println("Enter the number of registers : ");
t = sc.nextInt();
for (int i = 0; i < t; i++) {
//System.out.println("Enter the serial number of the book : ");
temp = sc.nextInt();
map.put(temp, books.get(temp - 1));
books.remove(temp-1);
}
execute();
}
static void execute() {
for (Integer a : map.keySet()) {
System.out.println(map.get(a));
}
}
public static void main(String[] args) {
Codechef ob = new Codechef();
//System.out.println("Enter the number of books : ");
while(sc.hasNext())
ob.input(sc.nextInt());
}
}