Submission #1306173


Source Code Expand

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 C = sc.nextInt();
        int K = sc.nextInt();
        int[] T = new int[N];
        for (int i = 0; i < N; ++i) {
            T[i] = sc.nextInt();
        }
        Arrays.sort(T);

        int min = 0;
        int start = K;
        int busCnt = 0;
        int pCnt = 0;
        for (int i = 0; i < N; ++i) {
            if (i == 0) {
                min = T[i];
                start = T[i] + K;
                ++pCnt;
                ++busCnt;
            } else {
                if (T[i] > start) {
                    min = T[i];
                    start = T[i] + K;
                    ++pCnt;
                    ++busCnt;
                } else if (pCnt >= C) {
                    min = T[i];
                    start = T[i] + K;
                    pCnt = 1;
                    ++busCnt;
                } else {
                    min = T[i];
                    ++pCnt;
                }
            }
        }
        _out.println(busCnt);
    }
    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 Info

Submission Time
Task A - Airport Bus
User hhelibex
Language Java8 (OpenJDK 1.8.0)
Score 0
Code Size 2451 Byte
Status WA
Exec Time 520 ms
Memory 48644 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 300
Status
AC × 2
AC × 8
WA × 4
Set Name Test Cases
Sample sample1.txt, sample2.txt
All sample1.txt, sample2.txt, in1.txt, in2.txt, in3.txt, in4.txt, in5.txt, in6.txt, in7.txt, in8.txt, sample1.txt, sample2.txt
Case Name Status Exec Time Memory
in1.txt AC 117 ms 20180 KB
in2.txt AC 473 ms 48644 KB
in3.txt WA 469 ms 45928 KB
in4.txt AC 496 ms 46332 KB
in5.txt WA 140 ms 23396 KB
in6.txt AC 520 ms 48476 KB
in7.txt WA 456 ms 47480 KB
in8.txt WA 485 ms 46756 KB
sample1.txt AC 92 ms 21204 KB
sample2.txt AC 94 ms 19540 KB