package no447; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.ArrayList; import java.util.HashMap; import java.util.InputMismatchException; import java.util.NoSuchElementException; public class Main { public static void main(String[] args) { IO io = new IO(); int n = io.nextInt(); int[] level = io.nextIntArray(n); int[] solved = new int[n]; int m = io.nextInt(); HashMap hm = new HashMap<>(); for(int i=0;i al = new ArrayList<>(hm.values()); for(Contestant ct: al) { for(int s: ct.score) { ct.sum += s; } } al.sort((c1,c2) -> { if (c1.sum != c2.sum) { return -Integer.compare(c1.sum, c2.sum); } return Integer.compare(c1.lastACTime, c2.lastACTime); }); for(int i=0;i Integer.MAX_VALUE) { throw new NumberFormatException(); } return (int) nl; } public char nextChar() { if (!hasNext()) { throw new NoSuchElementException(); } return (char) readByte(); } public double nextDouble() { return Double.parseDouble(next());} public int[] nextIntArray(int n) { int[] a = new int[n]; for(int i=0;i