AtCoder Beginner Contest 014

Submission #3979339

Source codeソースコード

import java.io.IOException;
import java.util.NoSuchElementException;

import java.io.InputStream;

import java.io.PrintWriter;

import java.util.Arrays;

@SuppressWarnings("unchecked")
public class Main {
    static final int MAX_N = 1000002;

    public static void main(String[] args) throws IOException {
        PrintWriter out = new PrintWriter(System.out);

        final int n = nextInt();

        int[] ab = new int[MAX_N];

        Arrays.fill(ab, 0);

        // 濃さ 0 有り
        for (int i = 0; i < n; i++) {
            ab[nextInt()]++;
            ab[nextInt() + 1]--;
        }

        int ans = ab[0];

        for (int i = 1; i < MAX_N; i++) {
            ab[i] += ab[i - 1];
            ans = Math.max(ans, ab[i]);
        }

        out.println(ans);

        out.flush();
    }

    // FastScanner start
    static final InputStream in = System.in;
    static final byte[] buffer = new byte[1024];
    static int ptr = 0;
    static int buflen = 0;
    static boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    static int readByte() {
        if (hasNextByte()) return buffer[ptr++];
        else return -1;
    }
    static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }
    static boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;
        return hasNextByte();
    }
    static String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    static long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if(b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    static int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }
    static double nextDouble() {
        return Double.parseDouble(next());
    }
    // FastScanner end
}

Submission

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

Test case

Set

Set name Score得点 / Max score Cases
Sample - subtask0_sample01.txt,subtask0_sample02.txt
Subtask1 30 / 30 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,subtask0_sample01.txt,subtask0_sample02.txt
Subtask2 70 / 70 subtask0_sample01.txt,subtask0_sample02.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,subtask2_01.txt,subtask2_02.txt,subtask2_03.txt,subtask2_04.txt,subtask2_05.txt,subtask2_06.txt,subtask2_07.txt,subtask2_08.txt,subtask2_09.txt,subtask2_10.txt,subtask2_11.txt,subtask2_12.txt,subtask2_13.txt,subtask2_14.txt,subtask2_15.txt,subtask2_16.txt,subtask2_17.txt,subtask2_18.txt,subtask2_19.txt,subtask2_20.txt,subtask2_21.txt,subtask2_22.txt,subtask2_23.txt,subtask2_24.txt,subtask2_25.txt

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
subtask0_sample01.txt AC 90 ms 20948 KB
subtask0_sample02.txt AC 87 ms 24148 KB
subtask1_01.txt AC 90 ms 22740 KB
subtask1_02.txt AC 88 ms 23252 KB
subtask1_03.txt AC 92 ms 24276 KB
subtask1_04.txt AC 96 ms 24532 KB
subtask1_05.txt AC 91 ms 25172 KB
subtask1_06.txt AC 97 ms 26324 KB
subtask1_07.txt AC 90 ms 25172 KB
subtask1_08.txt AC 95 ms 25556 KB
subtask1_09.txt AC 96 ms 25300 KB
subtask1_10.txt AC 95 ms 22484 KB
subtask1_11.txt AC 94 ms 25428 KB
subtask1_12.txt AC 95 ms 24276 KB
subtask1_13.txt AC 96 ms 26324 KB
subtask1_14.txt AC 90 ms 28116 KB
subtask1_15.txt AC 90 ms 25940 KB
subtask2_01.txt AC 106 ms 24020 KB
subtask2_02.txt AC 105 ms 26196 KB
subtask2_03.txt AC 105 ms 24404 KB
subtask2_04.txt AC 105 ms 22996 KB
subtask2_05.txt AC 106 ms 25044 KB
subtask2_06.txt AC 107 ms 22996 KB
subtask2_07.txt AC 105 ms 24276 KB
subtask2_08.txt AC 111 ms 25428 KB
subtask2_09.txt AC 106 ms 26324 KB
subtask2_10.txt AC 105 ms 24276 KB
subtask2_11.txt AC 106 ms 23252 KB
subtask2_12.txt AC 110 ms 22356 KB
subtask2_13.txt AC 108 ms 23124 KB
subtask2_14.txt AC 107 ms 28116 KB
subtask2_15.txt AC 106 ms 22996 KB
subtask2_16.txt AC 106 ms 24276 KB
subtask2_17.txt AC 106 ms 26836 KB
subtask2_18.txt AC 107 ms 24020 KB
subtask2_19.txt AC 109 ms 25812 KB
subtask2_20.txt AC 107 ms 22740 KB
subtask2_21.txt AC 105 ms 22612 KB
subtask2_22.txt AC 106 ms 25556 KB
subtask2_23.txt AC 109 ms 26196 KB
subtask2_24.txt AC 109 ms 26068 KB
subtask2_25.txt AC 108 ms 25428 KB