import java.io.*; import java.math.*; import java.time.*; import java.util.*; import java.util.Map.Entry; import java.util.stream.Collectors; class Main implements Runnable { public static void solve () { int n = nextInt(); int[] a = nextIntArray(n); int[] count = new int[21]; for (int i=0; i { int id, from, to, cost; Edge(int to, int cost) { //基本コレ this.to = to; this.cost = cost; } Edge(int from, int to, int cost) { this.from = from; this.to = to; this.cost = cost; } Edge(int id, int from, int to, int cost) { this.id = id; this.from = from; this.to = to; this.cost = cost; } @Override public int compareTo (Edge e) { return e.cost - this.cost; } } /* * ############################################################################################## * # input * ############################################################################################## */ // input - fields public static final InputStream in = System.in; public static final byte[] buffer = new byte[1024]; public static int ptr = 0; public static int bufferLength = 0; // input - basic methods public static boolean hasNextByte() { if (ptr < bufferLength) { return true; } else { ptr = 0; try { bufferLength = in.read(buffer); } catch (IOException e) { e.printStackTrace(); } if (bufferLength <= 0) { return false; } } return true; } public static int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1; } public static boolean isPrintableChar(int c) { return 33 <= c && c <= 126; } public static void skipUnprintable() { while (hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; } public static boolean hasNext() { skipUnprintable(); return hasNextByte(); } // input - single public static String next() { if (!hasNext()) throw new NoSuchElementException(); StringBuilder sb = new StringBuilder(); int b = readByte(); while (isPrintableChar(b)) { sb.appendCodePoint(b); b = readByte(); } return sb.toString(); } public static int nextInt() { return (int) nextLong(); } public static long nextLong() { if (!hasNext()) throw new NoSuchElementException(); long n = 0; boolean minus = false; int b = readByte(); if (b == '-') { minus = true; b = readByte(); } if (b < '0' || '9' < b) { throw new NumberFormatException(); } while (true) { if ('0' <= b && b <= '9') { n *= 10; n += b - '0'; } else if (b == -1 || !isPrintableChar(b)) { return minus ? -n : n; } else { throw new NumberFormatException(); } b = readByte(); } } public static double nextDouble() { return Double.parseDouble(next()); } // input - array public static String[] nextStringArray(int n) { String[] array = new String[n]; for (int i = 0; i < n; i++) array[i] = next(); return array; } public static int[] nextIntArray(int n) { int[] array = new int[n]; for (int i = 0; i < n; i++) array[i] = nextInt(); return array; } public static long[] nextLongArray(int n) { long[] array = new long[n]; for (int i = 0; i < n; i++) array[i] = nextLong(); return array; } public static double[] nextDoubleArray(int n) { double[] array = new double[n]; for (int i = 0; i < n; i++) { array[i] = nextDouble(); } return array; } // input - table public static char[][] nextCharTable(int h, int w) { char[][] array = new char[h][w]; for (int i = 0; i < h; i++) array[i] = next().toCharArray(); return array; } public static int[][] nextIntTable(int h, int w) { int[][] a = new int[h][]; for (int i=0; i