Submission #345554


Source Code Expand

Copy
import java.io.*;
import java.util.*;

public class Main {
    void run() {
        int N = readInt();
        ArrayList<Integer> values = new ArrayList<>();
        for (int i = 0; i < N; i++) {
            values.add(readInt());
        }
        HashSet<Integer> set = new HashSet<>();
        set.addAll(values);
        Collections.sort(values);
        int s = 0;
        for (int x : values) {
            if (set.contains(x) == false) continue;
            s++;
            for (int y = 2 * x; y <= 1000000000; y *= 2) {
                if (set.contains(y)) {
                    set.remove(y);
                }
            }
        }
        sysout.println(s);
    }

    public static void main(String[] args) {
        new Main().run();
    }

    // flush automatically iff you call `println` or `printf` or `format`.
    PrintWriter sysout = new PrintWriter(System.out, true);

    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer buffer = new StringTokenizer("");

    String read() {
        if (!buffer.hasMoreTokens()) {
            try {
                buffer = new StringTokenizer(in.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return buffer.nextToken();
    }

    int readInt() {
        return Integer.parseInt(read());
    }

    long readLong() {
        return Long.parseLong(read());
    }

    double readDouble() {
        return Double.parseDouble(read());
    }

    String readLine() {
        buffer = new StringTokenizer("");
        try {
            return in.readLine();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
}

Submission Info

Submission Time
Task C - 高橋くんと魔法の箱
User arosh
Language Java (OpenJDK 1.7.0)
Score 100
Code Size 1804 Byte
Status
Exec Time 1084 ms
Memory 43724 KB

Judge Result

Set Name Score / Max Score Test Cases
Sample 0 / 0 subtask0_0.txt, subtask0_1.txt, subtask0_2.txt
Subtask1 20 / 20 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 30 / 30 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 50 / 50 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 416 ms 20856 KB
subtask0_1.txt 416 ms 20984 KB
subtask0_2.txt 410 ms 20832 KB
subtask1_0.txt 502 ms 25876 KB
subtask1_1.txt 536 ms 25804 KB
subtask1_10.txt 520 ms 25896 KB
subtask1_11.txt 520 ms 25456 KB
subtask1_12.txt 539 ms 25296 KB
subtask1_13.txt 544 ms 25416 KB
subtask1_14.txt 533 ms 25532 KB
subtask1_15.txt 532 ms 25520 KB
subtask1_16.txt 554 ms 25136 KB
subtask1_17.txt 858 ms 25100 KB
subtask1_18.txt 525 ms 24872 KB
subtask1_19.txt 518 ms 25016 KB
subtask1_2.txt 542 ms 25480 KB
subtask1_3.txt 598 ms 25280 KB
subtask1_4.txt 542 ms 25832 KB
subtask1_5.txt 531 ms 25436 KB
subtask1_6.txt 539 ms 25440 KB
subtask1_7.txt 546 ms 25600 KB
subtask1_8.txt 553 ms 25968 KB
subtask1_9.txt 552 ms 25848 KB
subtask2_0.txt 816 ms 41248 KB
subtask2_1.txt 940 ms 42376 KB
subtask2_2.txt 937 ms 42464 KB
subtask2_3.txt 951 ms 42336 KB
subtask2_4.txt 950 ms 41676 KB
subtask2_5.txt 947 ms 42008 KB
subtask2_6.txt 932 ms 42616 KB
subtask2_7.txt 961 ms 42872 KB
subtask2_8.txt 931 ms 41776 KB
subtask2_9.txt 938 ms 42844 KB
subtask3_0.txt 777 ms 41040 KB
subtask3_1.txt 884 ms 43724 KB
subtask3_2.txt 917 ms 42644 KB
subtask3_3.txt 913 ms 43540 KB
subtask3_4.txt 1084 ms 42292 KB
subtask3_5.txt 933 ms 43340 KB
subtask3_6.txt 917 ms 43152 KB
subtask3_7.txt 921 ms 43220 KB
subtask3_8.txt 908 ms 43296 KB
subtask3_9.txt 900 ms 42436 KB