Submission #991157


Source Code Expand

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

    static BufferedReader in;
    static PrintWriter out;
    static StringTokenizer tok;

    void solve() throws IOException {
        int n = ni();
        String[] s = nsa(n);

        int[] cnt = new int[12 * 24 + 2];

        for (int i = 0; i < n; i++) {
            int sh = Integer.valueOf(s[i].substring(0, 2));
            int sm = Integer.valueOf(s[i].substring(2, 4));
            int th = Integer.valueOf(s[i].substring(5, 7));
            int tm = Integer.valueOf(s[i].substring(7, 9));

            cnt[(sh * 60 + sm) / 5]++;
            cnt[(th * 60 + tm + 4) / 5]--;
        }

        for (int i = 1; i < 12 * 24 + 2; i++) {
            cnt[i] += cnt[i - 1];
        }

        int idx = 0;
        boolean flg = false;
        String tmp = "";
        while (idx < 12 * 24 + 2){
            if (!flg && cnt[idx] > 0) {
                flg = true;
                int h = (idx * 5) / 60;
                int m = (idx * 5) % 60;
                tmp = String.format("%02d%02d", h, m);
            } else if (flg && cnt[idx] == 0) {
                int h = (idx * 5) / 60;
                int m = (idx * 5) % 60;
                tmp += String.format("-%02d%02d", h, m);
                out.println(tmp);
                flg = false;
            }
            idx++;
        }
    }

    String ns() throws IOException {
        while (!tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine(), " ");
        }
        return tok.nextToken();
    }

    int ni() throws IOException {
        return Integer.parseInt(ns());
    }

    long nl() throws IOException {
        return Long.parseLong(ns());
    }

    double nd() throws IOException {
        return Double.parseDouble(ns());
    }

    String[] nsa(int n) throws IOException {
        String[] res = new String[n];
        for (int i = 0; i < n; i++) {
            res[i] = ns();
        }
        return res;
    }

    int[] nia(int n) throws IOException {
        int[] res = new int[n];
        for (int i = 0; i < n; i++) {
            res[i] = ni();
        }
        return res;
    }

    long[] nla(int n) throws IOException {
        long[] res = new long[n];
        for (int i = 0; i < n; i++) {
            res[i] = nl();
        }
        return res;
    }

    public static void main(String[] args) throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        tok = new StringTokenizer("");
        Main main = new Main();
        main.solve();
        out.close();
    }
}

Submission Info

Submission Time
Task D - 感雨時刻の整理
User CrazyBBB
Language Java (OpenJDK 1.7.0)
Score 100
Code Size 2842 Byte
Status AC
Exec Time 365 ms
Memory 26656 KB

Judge Result

Set Name all
Score / Max Score 100 / 100
Status
AC × 48
Set Name Test Cases
all 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt, cho_cho_chokudai.txt, chokudai_ga_cho.txt, test_01.txt, test_02.txt, test_03.txt, test_04.txt, test_05.txt, test_06.txt, test_07.txt, test_08.txt, test_09.txt, test_10.txt, test_11.txt, test_12.txt, test_13.txt, test_14.txt, test_15.txt, test_16.txt, test_17.txt, test_18.txt, test_19.txt, test_20.txt, test_21.txt, test_22.txt, test_23.txt, test_24.txt, test_25.txt, test_26.txt, test_27.txt, test_28.txt, test_29.txt, test_30.txt, test_31.txt, test_32.txt, test_33.txt, test_34.txt, test_35.txt, test_36.txt, test_37.txt, test_38.txt, test_39.txt, test_40.txt, test_41.txt, test_42.txt, test_43.txt
Case Name Status Exec Time Memory
00_sample_01.txt AC 230 ms 12464 KB
00_sample_02.txt AC 178 ms 12412 KB
00_sample_03.txt AC 182 ms 12440 KB
cho_cho_chokudai.txt AC 358 ms 25860 KB
chokudai_ga_cho.txt AC 315 ms 25220 KB
test_01.txt AC 208 ms 13820 KB
test_02.txt AC 213 ms 13928 KB
test_03.txt AC 211 ms 13880 KB
test_04.txt AC 209 ms 13800 KB
test_05.txt AC 209 ms 13876 KB
test_06.txt AC 186 ms 12480 KB
test_07.txt AC 181 ms 12524 KB
test_08.txt AC 182 ms 12460 KB
test_09.txt AC 191 ms 13044 KB
test_10.txt AC 190 ms 13060 KB
test_11.txt AC 190 ms 13044 KB
test_12.txt AC 187 ms 13040 KB
test_13.txt AC 183 ms 12440 KB
test_14.txt AC 193 ms 13000 KB
test_15.txt AC 190 ms 13104 KB
test_16.txt AC 181 ms 12432 KB
test_17.txt AC 188 ms 13052 KB
test_18.txt AC 182 ms 12452 KB
test_19.txt AC 188 ms 13096 KB
test_20.txt AC 189 ms 13088 KB
test_21.txt AC 359 ms 26268 KB
test_22.txt AC 321 ms 25392 KB
test_23.txt AC 347 ms 26656 KB
test_24.txt AC 339 ms 25432 KB
test_25.txt AC 342 ms 25212 KB
test_26.txt AC 363 ms 25952 KB
test_27.txt AC 362 ms 26304 KB
test_28.txt AC 365 ms 26076 KB
test_29.txt AC 177 ms 12448 KB
test_30.txt AC 184 ms 12528 KB
test_31.txt AC 257 ms 17216 KB
test_32.txt AC 179 ms 12404 KB
test_33.txt AC 346 ms 23372 KB
test_34.txt AC 178 ms 12428 KB
test_35.txt AC 197 ms 12764 KB
test_36.txt AC 364 ms 26140 KB
test_37.txt AC 365 ms 26140 KB
test_38.txt AC 340 ms 26332 KB
test_39.txt AC 361 ms 26228 KB
test_40.txt AC 352 ms 26144 KB
test_41.txt AC 359 ms 25852 KB
test_42.txt AC 356 ms 26200 KB
test_43.txt AC 357 ms 25700 KB