AtCoder Beginner Contest 019

Submission #345554

Source codeソースコード

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

Task問題 C - 高橋くんと魔法の箱
User nameユーザ名 arosh
Created time投稿日時
Language言語 Java (OpenJDK 1.7.0)
Status状態 AC
Score得点 100
Source lengthソースコード長 1804 Byte
File nameファイル名
Exec time実行時間 1084 ms
Memory usageメモリ使用量 43724 KB

Test case

Set

Set name Score得点 / Max score Cases
Sample - 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

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
subtask0_0.txt AC 416 ms 20856 KB
subtask0_1.txt AC 416 ms 20984 KB
subtask0_2.txt AC 410 ms 20832 KB
subtask1_0.txt AC 502 ms 25876 KB
subtask1_1.txt AC 536 ms 25804 KB
subtask1_10.txt AC 520 ms 25896 KB
subtask1_11.txt AC 520 ms 25456 KB
subtask1_12.txt AC 539 ms 25296 KB
subtask1_13.txt AC 544 ms 25416 KB
subtask1_14.txt AC 533 ms 25532 KB
subtask1_15.txt AC 532 ms 25520 KB
subtask1_16.txt AC 554 ms 25136 KB
subtask1_17.txt AC 858 ms 25100 KB
subtask1_18.txt AC 525 ms 24872 KB
subtask1_19.txt AC 518 ms 25016 KB
subtask1_2.txt AC 542 ms 25480 KB
subtask1_3.txt AC 598 ms 25280 KB
subtask1_4.txt AC 542 ms 25832 KB
subtask1_5.txt AC 531 ms 25436 KB
subtask1_6.txt AC 539 ms 25440 KB
subtask1_7.txt AC 546 ms 25600 KB
subtask1_8.txt AC 553 ms 25968 KB
subtask1_9.txt AC 552 ms 25848 KB
subtask2_0.txt AC 816 ms 41248 KB
subtask2_1.txt AC 940 ms 42376 KB
subtask2_2.txt AC 937 ms 42464 KB
subtask2_3.txt AC 951 ms 42336 KB
subtask2_4.txt AC 950 ms 41676 KB
subtask2_5.txt AC 947 ms 42008 KB
subtask2_6.txt AC 932 ms 42616 KB
subtask2_7.txt AC 961 ms 42872 KB
subtask2_8.txt AC 931 ms 41776 KB
subtask2_9.txt AC 938 ms 42844 KB
subtask3_0.txt AC 777 ms 41040 KB
subtask3_1.txt AC 884 ms 43724 KB
subtask3_2.txt AC 917 ms 42644 KB
subtask3_3.txt AC 913 ms 43540 KB
subtask3_4.txt AC 1084 ms 42292 KB
subtask3_5.txt AC 933 ms 43340 KB
subtask3_6.txt AC 917 ms 43152 KB
subtask3_7.txt AC 921 ms 43220 KB
subtask3_8.txt AC 908 ms 43296 KB
subtask3_9.txt AC 900 ms 42436 KB