Submission #522491


Source Code Expand

import java.math.BigDecimal;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;

public class Main {
    public static void main(String[] argv) {
        Scanner scanner = new Scanner(System.in);
        int time = scanner.nextInt();
        String[] lines = new String[time];
        HashMap<Integer, Integer> starts = new HashMap<Integer, Integer>();
        for (int i = 0; i < time; i++) {
            String l = scanner.next();
            lines[i] = l;
            int s = Integer.parseInt(l.split("-")[0]);
            starts.put(s, i);
        }
        Object[] key = starts.keySet().toArray();
        Arrays.sort(key);

        int index = 0;
        BigDecimal bds;
        BigDecimal bde;
        BigDecimal bdls = BigDecimal.valueOf(0);
        BigDecimal bdle = BigDecimal.valueOf(0);
        String[] out = new String[time];
        for (int i = 0; i < key.length; i++) {
            int k = starts.get(key[i]);
            String[] tmp = lines[k].split("-");
            bds = new BigDecimal(tmp[0]);
            BigDecimal s = bds.divide(BigDecimal.TEN, BigDecimal.ROUND_FLOOR);
            if (bds.remainder(BigDecimal.TEN).intValue() >= 5) {
                bds = s.multiply(BigDecimal.TEN).add(BigDecimal.valueOf(5));
            } else {
                bds = s.multiply(BigDecimal.TEN);
            }
            if (bds.remainder(BigDecimal.valueOf(100)).intValue() > 59) {
                bds = bds.add(BigDecimal.valueOf(40));
            }

            bde = new BigDecimal(tmp[1]);
            BigDecimal e = bde.divide(BigDecimal.TEN, BigDecimal.ROUND_FLOOR);
            if (bde.remainder(BigDecimal.TEN).intValue() >= 5) {
                bde = e.multiply(BigDecimal.TEN).add(BigDecimal.valueOf(10));
            } else if (bde.remainder(BigDecimal.TEN).intValue() >= 1) {
                bde = e.multiply(BigDecimal.TEN).add(BigDecimal.valueOf(5));
            } else {
                bde = e.multiply(BigDecimal.TEN);
            }
            if (bde.remainder(BigDecimal.valueOf(100)).intValue() > 59) {
                bde = bde.add(BigDecimal.valueOf(40));
            }
            if (bde.intValue() > 2359) {
                bde = BigDecimal.valueOf(2400);
            }
            if (i > 0) {
                if (bds.compareTo(bdls) < 0) {
                    if (bde.compareTo(bdle) > 0) {
                        out[index - 1] = String.format("%04d-%04d", bds.intValue(), bde.intValue());
                        bdls = bds;
                        bdle = bde;
                    } else {
                        out[index - 1] = String.format("%04d-%04d", bds.intValue(), bdle.intValue());
                        bdls = bds;
                    }
                    continue;
                } else if (bds.compareTo(bdle) <= 0 && bde.compareTo(bdle) > 0) {
                    out[index-1] = String.format("%04d-%04d", bdls.intValue(), bde.intValue());
                    bdle = bde;
                    continue;
                } else if (bde.compareTo(bdle) <= 0) {
                    continue;
                }
            }
            out[index] = String.format("%04d-%04d", bds.intValue(), bde.intValue());
            bdls = bds;
            bdle = bde;
            index++;
        }

        for (int i = 0; i < out.length; i++) {
           if (out[i] == null) {
               break;
           }
           System.out.println(out[i]);
        }
    }
}

Submission Info

Submission Time
Task D - 感雨時刻の整理
User delaemon
Language Java (OpenJDK 1.7.0)
Score 0
Code Size 3533 Byte
Status WA
Exec Time 1270 ms
Memory 44856 KB

Judge Result

Set Name all
Score / Max Score 0 / 100
Status
AC × 35
WA × 13
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 568 ms 24380 KB
00_sample_02.txt AC 455 ms 24300 KB
00_sample_03.txt AC 417 ms 24252 KB
cho_cho_chokudai.txt AC 881 ms 40276 KB
chokudai_ga_cho.txt AC 1270 ms 44644 KB
test_01.txt WA 529 ms 26508 KB
test_02.txt WA 534 ms 26496 KB
test_03.txt WA 532 ms 26448 KB
test_04.txt WA 541 ms 26520 KB
test_05.txt WA 522 ms 26532 KB
test_06.txt AC 592 ms 30592 KB
test_07.txt AC 557 ms 27756 KB
test_08.txt AC 501 ms 26176 KB
test_09.txt AC 484 ms 26508 KB
test_10.txt AC 553 ms 28516 KB
test_11.txt AC 477 ms 25224 KB
test_12.txt AC 680 ms 36180 KB
test_13.txt AC 609 ms 31728 KB
test_14.txt AC 727 ms 38248 KB
test_15.txt AC 707 ms 36520 KB
test_16.txt AC 526 ms 27744 KB
test_17.txt AC 675 ms 36076 KB
test_18.txt AC 560 ms 29368 KB
test_19.txt AC 667 ms 34448 KB
test_20.txt AC 682 ms 35932 KB
test_21.txt AC 1236 ms 44792 KB
test_22.txt AC 1218 ms 44472 KB
test_23.txt AC 1258 ms 44856 KB
test_24.txt AC 1219 ms 44696 KB
test_25.txt AC 1242 ms 44736 KB
test_26.txt AC 1178 ms 44224 KB
test_27.txt AC 917 ms 40336 KB
test_28.txt WA 1176 ms 44272 KB
test_29.txt AC 409 ms 24256 KB
test_30.txt WA 508 ms 25028 KB
test_31.txt WA 907 ms 37340 KB
test_32.txt WA 440 ms 24872 KB
test_33.txt WA 1132 ms 42816 KB
test_34.txt AC 413 ms 24324 KB
test_35.txt WA 530 ms 26752 KB
test_36.txt AC 1189 ms 43736 KB
test_37.txt WA 1182 ms 44352 KB
test_38.txt AC 1139 ms 44664 KB
test_39.txt AC 1122 ms 43920 KB
test_40.txt WA 1118 ms 43832 KB
test_41.txt AC 977 ms 42604 KB
test_42.txt AC 982 ms 41388 KB
test_43.txt AC 983 ms 42196 KB