Submission #1178225
Source Code Expand
import java.io.*; import java.util.*; public class Main { private static Scanner sc; private static Printer pr; private static void solve() { int n = 0x1 << sc.nextInt(); int[] a = new int[n]; for (int i = 0; i < n; i++) { a[i] = sc.nextInt(); } while (n > 1) { n /= 2; int[] tmp = new int[n]; for (int i = 0; i < n; i++) { if (a[2 * i] == a[2 * i + 1]) { tmp[i] = a[2 * i]; } else { tmp[i] = Math.abs(a[2 * i] - a[2 * i + 1]); } } a = tmp; } pr.println(a[0]); } // --------------------------------------------------- public static void main(String[] args) { sc = new Scanner(System.in); pr = new Printer(System.out); solve(); pr.close(); sc.close(); } @SuppressWarnings("unused") private static class Scanner { BufferedReader br; Scanner (InputStream in) { br = new BufferedReader(new InputStreamReader(in)); } private boolean isPrintable(int ch) { return ch >= '!' && ch <= '~'; } private boolean isCRLF(int ch) { return ch == '\n' || ch == '\r' || ch == -1; } private int nextPrintable() { try { int ch; while (!isPrintable(ch = br.read())) { if (ch == -1) { throw new NoSuchElementException(); } } return ch; } catch (IOException e) { throw new NoSuchElementException(); } } String next() { try { int ch = nextPrintable(); StringBuilder sb = new StringBuilder(); do { sb.appendCodePoint(ch); } while (isPrintable(ch = br.read())); return sb.toString(); } catch (IOException e) { throw new NoSuchElementException(); } } int nextInt() { try { // parseInt from Integer.parseInt() boolean negative = false; int res = 0; int limit = -Integer.MAX_VALUE; int radix = 10; int fc = nextPrintable(); if (fc < '0') { if (fc == '-') { negative = true; limit = Integer.MIN_VALUE; } else if (fc != '+') { throw new NumberFormatException(); } fc = br.read(); } int multmin = limit / radix; int ch = fc; do { int digit = ch - '0'; if (digit < 0 || digit >= radix) { throw new NumberFormatException(); } if (res < multmin) { throw new NumberFormatException(); } res *= radix; if (res < limit + digit) { throw new NumberFormatException(); } res -= digit; } while (isPrintable(ch = br.read())); return negative ? res : -res; } catch (IOException e) { throw new NoSuchElementException(); } } long nextLong() { try { // parseLong from Long.parseLong() boolean negative = false; long res = 0; long limit = -Long.MAX_VALUE; int radix = 10; int fc = nextPrintable(); if (fc < '0') { if (fc == '-') { negative = true; limit = Long.MIN_VALUE; } else if (fc != '+') { throw new NumberFormatException(); } fc = br.read(); } long multmin = limit / radix; int ch = fc; do { int digit = ch - '0'; if (digit < 0 || digit >= radix) { throw new NumberFormatException(); } if (res < multmin) { throw new NumberFormatException(); } res *= radix; if (res < limit + digit) { throw new NumberFormatException(); } res -= digit; } while (isPrintable(ch = br.read())); return negative ? res : -res; } catch (IOException e) { throw new NoSuchElementException(); } } float nextFloat() { return Float.parseFloat(next()); } double nextDouble() { return Double.parseDouble(next()); } String nextLine() { try { int ch; while (isCRLF(ch = br.read())) { if (ch == -1) { throw new NoSuchElementException(); } } StringBuilder sb = new StringBuilder(); do { sb.appendCodePoint(ch); } while (!isCRLF(ch = br.read())); return sb.toString(); } catch (IOException e) { throw new NoSuchElementException(); } } void close() { try { br.close(); } catch (IOException e) { // throw new NoSuchElementException(); } } } private static class Printer extends PrintWriter { Printer(PrintStream out) { super(out); } } }
Submission Info
Submission Time | |
---|---|
Task | C - Kode Festival |
User | garnacha |
Language | Java8 (OpenJDK 1.8.0) |
Score | 100 |
Code Size | 4448 Byte |
Status | AC |
Exec Time | 180 ms |
Memory | 26148 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 100 / 100 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | sample_01.txt, sample_02.txt |
All | sample_01.txt, sample_02.txt, sample_01.txt, sample_02.txt, subtask1_01.txt, subtask1_02.txt, subtask1_03.txt, subtask1_04.txt, subtask1_05.txt, subtask1_06.txt, subtask1_07.txt, subtask1_08.txt, subtask1_09.txt, subtask1_10.txt, subtask1_11.txt, subtask1_12.txt, subtask1_13.txt, subtask1_14.txt, subtask1_15.txt, subtask1_16.txt, subtask1_17.txt, subtask1_18.txt, subtask1_19.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
sample_01.txt | AC | 76 ms | 21460 KB |
sample_02.txt | AC | 70 ms | 19028 KB |
subtask1_01.txt | AC | 70 ms | 19796 KB |
subtask1_02.txt | AC | 69 ms | 19540 KB |
subtask1_03.txt | AC | 71 ms | 19924 KB |
subtask1_04.txt | AC | 69 ms | 21460 KB |
subtask1_05.txt | AC | 101 ms | 20948 KB |
subtask1_06.txt | AC | 69 ms | 19540 KB |
subtask1_07.txt | AC | 111 ms | 21204 KB |
subtask1_08.txt | AC | 131 ms | 25428 KB |
subtask1_09.txt | AC | 82 ms | 19284 KB |
subtask1_10.txt | AC | 164 ms | 24268 KB |
subtask1_11.txt | AC | 169 ms | 22864 KB |
subtask1_12.txt | AC | 165 ms | 26148 KB |
subtask1_13.txt | AC | 164 ms | 25684 KB |
subtask1_14.txt | AC | 175 ms | 22484 KB |
subtask1_15.txt | AC | 163 ms | 24396 KB |
subtask1_16.txt | AC | 180 ms | 24140 KB |
subtask1_17.txt | AC | 161 ms | 24532 KB |
subtask1_18.txt | AC | 170 ms | 25116 KB |
subtask1_19.txt | AC | 165 ms | 23376 KB |