Submission #345422
Source Code Expand
import java.io.*; import java.math.*; import java.util.*; import static java.util.Arrays.*; public class Main { private static final int mod = (int)1e9+7; final Random random = new Random(0); final IOFast io = new IOFast(); /// MAIN CODE public void run() throws IOException { // int TEST_CASE = Integer.parseInt(new String(io.nextLine()).trim()); int TEST_CASE = 1; while(TEST_CASE-- != 0) { int n = io.nextInt(); TreeSet<Integer> set = new TreeSet<>(); for(int i = 0; i < n; i++) { set.add(io.nextInt()); } int ans = 0; while(!set.isEmpty()) { for(int v = set.pollFirst(); v <= mod; v *= 2) { set.remove(v); } ans++; } io.out.println(ans); } } /// TEMPLATE static int gcd(int n, int r) { return r == 0 ? n : gcd(r, n%r); } static long gcd(long n, long r) { return r == 0 ? n : gcd(r, n%r); } static <T> void swap(T[] x, int i, int j) { T t = x[i]; x[i] = x[j]; x[j] = t; } static void swap(int[] x, int i, int j) { int t = x[i]; x[i] = x[j]; x[j] = t; } void main() throws IOException { // IOFast.setFileIO("rle-size.in", "rle-size.out"); try { run(); } catch (EndOfFileRuntimeException e) { } io.out.flush(); } public static void main(String[] args) throws IOException { new Main().main(); } static class EndOfFileRuntimeException extends RuntimeException { private static final long serialVersionUID = -8565341110209207657L; } static public class IOFast { private BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); private PrintWriter out = new PrintWriter(System.out); void setFileIn(String ins) throws IOException { in.close(); in = new BufferedReader(new FileReader(ins)); } void setFileOut(String outs) throws IOException { out.flush(); out.close(); out = new PrintWriter(new FileWriter(outs)); } void setFileIO(String ins, String outs) throws IOException { setFileIn(ins); setFileOut(outs); } private static int pos, readLen; private static final char[] buffer = new char[1024 * 8]; private static char[] str = new char[500*8*2]; private static boolean[] isDigit = new boolean[256]; private static boolean[] isSpace = new boolean[256]; private static boolean[] isLineSep = new boolean[256]; static { for(int i = 0; i < 10; i++) { isDigit['0' + i] = true; } isDigit['-'] = true; isSpace[' '] = isSpace['\r'] = isSpace['\n'] = isSpace['\t'] = true; isLineSep['\r'] = isLineSep['\n'] = true; } public int read() throws IOException { if(pos >= readLen) { pos = 0; readLen = in.read(buffer); if(readLen <= 0) { throw new EndOfFileRuntimeException(); } } return buffer[pos++]; } public int nextInt() throws IOException { int len = 0; str[len++] = nextChar(); len = reads(len, isSpace); int i = 0; int ret = 0; if(str[0] == '-') { i = 1; } for(; i < len; i++) ret = ret * 10 + str[i] - '0'; if(str[0] == '-') { ret = -ret; } return ret; } public long nextLong() throws IOException { int len = 0; str[len++] = nextChar(); len = reads(len, isSpace); int i = 0; long ret = 0; if(str[0] == '-') { i = 1; } for(; i < len; i++) ret = ret * 10 + str[i] - '0'; if(str[0] == '-') { ret = -ret; } return ret; } public char nextChar() throws IOException { while(true) { final int c = read(); if(!isSpace[c]) { return (char)c; } } } int reads(int len, boolean[] accept) throws IOException { try { while(true) { final int c = read(); if(accept[c]) { break; } if(str.length == len) { char[] rep = new char[str.length * 3 / 2]; System.arraycopy(str, 0, rep, 0, str.length); str = rep; } str[len++] = (char)c; } } catch(EndOfFileRuntimeException e) { ; } return len; } int reads(char[] cs, int len, boolean[] accept) throws IOException { try { while(true) { final int c = read(); if(accept[c]) { break; } cs[len++] = (char)c; } } catch(EndOfFileRuntimeException e) { ; } return len; } public char[] nextLine() throws IOException { int len = 0; str[len++] = nextChar(); len = reads(len, isLineSep); try { if(str[len-1] == '\r') { len--; read(); } } catch(EndOfFileRuntimeException e) { ; } return Arrays.copyOf(str, len); } public String nextString() throws IOException { return new String(next()); } public char[] next() throws IOException { int len = 0; str[len++] = nextChar(); len = reads(len, isSpace); return Arrays.copyOf(str, len); } public int next(char[] cs) throws IOException { int len = 0; cs[len++] = nextChar(); len = reads(cs, len, isSpace); return len; } public double nextDouble() throws IOException { return Double.parseDouble(nextString()); } public long[] nextLongArray(final int n) throws IOException { final long[] res = new long[n]; for(int i = 0; i < n; i++) { res[i] = nextLong(); } return res; } public int[] nextIntArray(final int n) throws IOException { final int[] res = new int[n]; for(int i = 0; i < n; i++) { res[i] = nextInt(); } return res; } public int[][] nextIntArray2D(final int n, final int k) throws IOException { final int[][] res = new int[n][]; for(int i = 0; i < n; i++) { res[i] = nextIntArray(k); } return res; } public int[][] nextIntArray2DWithIndex(final int n, final int k) throws IOException { final int[][] res = new int[n][k+1]; for(int i = 0; i < n; i++) { for(int j = 0; j < k; j++) { res[i][j] = nextInt(); } res[i][k] = i; } return res; } public double[] nextDoubleArray(final int n) throws IOException { final double[] res = new double[n]; for(int i = 0; i < n; i++) { res[i] = nextDouble(); } return res; } } }
Submission Info
Submission Time | |
---|---|
Task | C - 高橋くんと魔法の箱 |
User | tanzaku |
Language | Java (OpenJDK 1.7.0) |
Score | 100 |
Code Size | 5521 Byte |
Status | AC |
Exec Time | 791 ms |
Memory | 37748 KB |
Judge Result
Set Name | Sample | Subtask1 | Subtask2 | All | ||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 20 / 20 | 30 / 30 | 50 / 50 | ||||||||
Status |
|
|
|
|
Set Name | Test Cases |
---|---|
Sample | subtask0_0.txt, subtask0_1.txt, subtask0_2.txt |
Subtask1 | subtask1_0.txt, subtask1_1.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, subtask1_2.txt, subtask1_3.txt, subtask1_4.txt, subtask1_5.txt, subtask1_6.txt, subtask1_7.txt, subtask1_8.txt, subtask1_9.txt, subtask0_0.txt, subtask0_1.txt, subtask0_2.txt |
Subtask2 | subtask2_0.txt, subtask2_1.txt, subtask2_2.txt, subtask2_3.txt, subtask2_4.txt, subtask2_5.txt, subtask2_6.txt, subtask2_7.txt, subtask2_8.txt, subtask2_9.txt, subtask0_0.txt, subtask0_1.txt, subtask0_2.txt |
All | subtask0_0.txt, subtask0_1.txt, subtask0_2.txt, subtask1_0.txt, subtask1_1.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, subtask1_2.txt, subtask1_3.txt, subtask1_4.txt, subtask1_5.txt, subtask1_6.txt, subtask1_7.txt, subtask1_8.txt, subtask1_9.txt, subtask2_0.txt, subtask2_1.txt, subtask2_2.txt, subtask2_3.txt, subtask2_4.txt, subtask2_5.txt, subtask2_6.txt, subtask2_7.txt, subtask2_8.txt, subtask2_9.txt, subtask3_0.txt, subtask3_1.txt, subtask3_2.txt, subtask3_3.txt, subtask3_4.txt, subtask3_5.txt, subtask3_6.txt, subtask3_7.txt, subtask3_8.txt, subtask3_9.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
subtask0_0.txt | AC | 322 ms | 20948 KB |
subtask0_1.txt | AC | 326 ms | 20972 KB |
subtask0_2.txt | AC | 316 ms | 20864 KB |
subtask1_0.txt | AC | 423 ms | 25744 KB |
subtask1_1.txt | AC | 427 ms | 25720 KB |
subtask1_10.txt | AC | 420 ms | 25364 KB |
subtask1_11.txt | AC | 409 ms | 24816 KB |
subtask1_12.txt | AC | 403 ms | 24952 KB |
subtask1_13.txt | AC | 412 ms | 24472 KB |
subtask1_14.txt | AC | 790 ms | 21652 KB |
subtask1_15.txt | AC | 495 ms | 24416 KB |
subtask1_16.txt | AC | 401 ms | 24516 KB |
subtask1_17.txt | AC | 396 ms | 24828 KB |
subtask1_18.txt | AC | 406 ms | 24672 KB |
subtask1_19.txt | AC | 400 ms | 24520 KB |
subtask1_2.txt | AC | 425 ms | 25252 KB |
subtask1_3.txt | AC | 441 ms | 25512 KB |
subtask1_4.txt | AC | 435 ms | 25120 KB |
subtask1_5.txt | AC | 434 ms | 25328 KB |
subtask1_6.txt | AC | 435 ms | 25108 KB |
subtask1_7.txt | AC | 433 ms | 25332 KB |
subtask1_8.txt | AC | 431 ms | 25168 KB |
subtask1_9.txt | AC | 426 ms | 25208 KB |
subtask2_0.txt | AC | 791 ms | 37496 KB |
subtask2_1.txt | AC | 717 ms | 37660 KB |
subtask2_2.txt | AC | 702 ms | 37680 KB |
subtask2_3.txt | AC | 717 ms | 37436 KB |
subtask2_4.txt | AC | 717 ms | 37572 KB |
subtask2_5.txt | AC | 714 ms | 37748 KB |
subtask2_6.txt | AC | 715 ms | 37152 KB |
subtask2_7.txt | AC | 714 ms | 36928 KB |
subtask2_8.txt | AC | 705 ms | 37100 KB |
subtask2_9.txt | AC | 698 ms | 37684 KB |
subtask3_0.txt | AC | 790 ms | 37576 KB |
subtask3_1.txt | AC | 700 ms | 36560 KB |
subtask3_2.txt | AC | 637 ms | 36988 KB |
subtask3_3.txt | AC | 667 ms | 36920 KB |
subtask3_4.txt | AC | 651 ms | 37084 KB |
subtask3_5.txt | AC | 648 ms | 36512 KB |
subtask3_6.txt | AC | 652 ms | 37012 KB |
subtask3_7.txt | AC | 647 ms | 36960 KB |
subtask3_8.txt | AC | 705 ms | 36828 KB |
subtask3_9.txt | AC | 708 ms | 36844 KB |