AtCoder Beginner Contest 030

Submission #1358524

Source codeソースコード

import java.io.*;
import java.math.*;
import java.util.*;

public class Main {
    private static boolean debug = false;
    private static boolean elapsed = false;

    private static PrintWriter _out = new PrintWriter(System.out);
    private static PrintWriter _err = new PrintWriter(System.err);

    private void solve(Scanner sc) {
        int N = sc.nextInt();
        int M = sc.nextInt();
        int X = sc.nextInt();
        int Y = sc.nextInt();
        NavigableSet<Integer> a = new TreeSet<>();
        for (int i = 0; i < N; ++i) {
            a.add(sc.nextInt());
        }
        NavigableSet<Integer> b = new TreeSet<>();
        for (int i = 0; i < M; ++i) {
            b.add(sc.nextInt());
        }

        int ans = 0;
        boolean flag = true;
        int cur = 0;
        do {
            flag = false;

            Integer aa = a.ceiling(cur);
            if (aa != null) {
                aa += X;
                Integer bb = b.ceiling(aa);
                if (bb != null) {
                    bb += Y;
                    cur = bb;
                    ++ans;
                    flag = true;
                }
            }
        } while (flag);
        _out.println(ans);
    }
    private static BigInteger C(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        for (long i = r; i > 1; --i) {
            res = res.divide(BigInteger.valueOf(i));
        }
        return res;
    }
    private static BigInteger P(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        return res;
    }
    /*
     * 10^10 > Integer.MAX_VALUE = 2147483647 > 10^9
     * 10^19 > Long.MAX_VALUE = 9223372036854775807L > 10^18
     */
    public static void main(String[] args) {
        long S = System.currentTimeMillis();

        Scanner sc = new Scanner(System.in);
        new Main().solve(sc);
        _out.flush();

        long G = System.currentTimeMillis();
        if (elapsed) {
            _err.println((G - S) + "ms");
        }
        _err.flush();
    }
}

Submission

Task問題 C - 飛行機乗り
User nameユーザ名 HHeLiBeX
Created time投稿日時
Language言語 Java8 (OpenJDK 1.8.0)
Status状態 AC
Score得点 100
Source lengthソースコード長 2314 Byte
File nameファイル名
Exec time実行時間 687 ms
Memory usageメモリ使用量 87984 KB

Test case

Set

Set name Score得点 / Max score Cases
Sample - subtask0_sample_01.txt,subtask0_sample_02.txt,subtask0_sample_03.txt
Subtask1 30 / 30 subtask0_0.txt,subtask0_1.txt,subtask0_10.txt,subtask0_11.txt,subtask0_12.txt,subtask0_13.txt,subtask0_14.txt,subtask0_2.txt,subtask0_3.txt,subtask0_4.txt,subtask0_5.txt,subtask0_6.txt,subtask0_7.txt,subtask0_8.txt,subtask0_9.txt,subtask0_sample_01.txt,subtask0_sample_02.txt,subtask0_sample_03.txt
All 70 / 70 subtask0_0.txt,subtask0_1.txt,subtask0_10.txt,subtask0_11.txt,subtask0_12.txt,subtask0_13.txt,subtask0_14.txt,subtask0_2.txt,subtask0_3.txt,subtask0_4.txt,subtask0_5.txt,subtask0_6.txt,subtask0_7.txt,subtask0_8.txt,subtask0_9.txt,subtask0_sample_01.txt,subtask0_sample_02.txt,subtask0_sample_03.txt,subtask1_0.txt,subtask1_1.txt,subtask1_10.txt,subtask1_11.txt,subtask1_12.txt,subtask1_13.txt,subtask1_14.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

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
subtask0_0.txt AC 630 ms 86356 KB
subtask0_1.txt AC 533 ms 65764 KB
subtask0_10.txt AC 552 ms 71096 KB
subtask0_11.txt AC 551 ms 71476 KB
subtask0_12.txt AC 631 ms 68880 KB
subtask0_13.txt AC 544 ms 70832 KB
subtask0_14.txt AC 562 ms 70512 KB
subtask0_2.txt AC 576 ms 71332 KB
subtask0_3.txt AC 572 ms 70728 KB
subtask0_4.txt AC 595 ms 69520 KB
subtask0_5.txt AC 507 ms 61500 KB
subtask0_6.txt AC 619 ms 81092 KB
subtask0_7.txt AC 572 ms 71204 KB
subtask0_8.txt AC 466 ms 63000 KB
subtask0_9.txt AC 666 ms 87668 KB
subtask0_sample_01.txt AC 94 ms 21972 KB
subtask0_sample_02.txt AC 98 ms 21716 KB
subtask0_sample_03.txt AC 98 ms 21716 KB
subtask1_0.txt AC 687 ms 87984 KB
subtask1_1.txt AC 654 ms 76008 KB
subtask1_10.txt AC 545 ms 65412 KB
subtask1_11.txt AC 590 ms 70044 KB
subtask1_12.txt AC 670 ms 82072 KB
subtask1_13.txt AC 664 ms 84268 KB
subtask1_14.txt AC 608 ms 67924 KB
subtask1_2.txt AC 627 ms 72272 KB
subtask1_3.txt AC 590 ms 71056 KB
subtask1_4.txt AC 615 ms 72772 KB
subtask1_5.txt AC 618 ms 70660 KB
subtask1_6.txt AC 619 ms 71452 KB
subtask1_7.txt AC 621 ms 70204 KB
subtask1_8.txt AC 610 ms 71588 KB
subtask1_9.txt AC 623 ms 80124 KB