Submission #522544
Source Code Expand
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; String[] t = l.split("-"); int s = Integer.parseInt(t[0] + t[1]); starts.put(s, i); } Object[] key = starts.keySet().toArray(); Arrays.sort(key); int index = 0; int bds; int bde; int bdls = 0; int bdle = 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 = Integer.parseInt(tmp[0]); double s = Math.floor(bds / 10); if (bds % 10 >= 5) { bds = (int)s * 10 + 5; } else { bds = (int)s * 10; } if (bds % 100 > 59) { bds = bds + 40; } bde = Integer.parseInt(tmp[1]); double e = Math.floor(bde / 10); if (bde % 10 > 5) { bde = (int)e * 10 + 10; } else if (bde % 10 >= 1) { bde = (int)e * 10 + 5; } else { bde = (int)e * 10; } if (bde % 100 > 59) { bde = bde + 40; } if (bde > 2359) { bde = 2400; } if (i > 0) { if (bds <= bdls) { if (bdle <= bde) { out[index - 1] = String.format("%04d-%04d", bds, bde); bdls = bds; bdle = bde; } else { out[index - 1] = String.format("%04d-%04d", bds, bdle); bdls = bds; } continue; } else if (bds <= bdle && bdle <= bde) { out[index - 1] = String.format("%04d-%04d", bdls, bde); bdle = bde; continue; } else if (bde <= bdle) { continue; } } out[index] = String.format("%04d-%04d", bds, bde); 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 | 100 |
Code Size | 2863 Byte |
Status | AC |
Exec Time | 1335 ms |
Memory | 45592 KB |
Judge Result
Set Name | all | ||
---|---|---|---|
Score / Max Score | 100 / 100 | ||
Status |
|
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 | 480 ms | 23488 KB |
00_sample_02.txt | AC | 463 ms | 23408 KB |
00_sample_03.txt | AC | 471 ms | 23492 KB |
cho_cho_chokudai.txt | AC | 1009 ms | 41980 KB |
chokudai_ga_cho.txt | AC | 1282 ms | 44964 KB |
test_01.txt | AC | 518 ms | 23860 KB |
test_02.txt | AC | 517 ms | 23896 KB |
test_03.txt | AC | 523 ms | 24052 KB |
test_04.txt | AC | 523 ms | 23980 KB |
test_05.txt | AC | 519 ms | 24016 KB |
test_06.txt | AC | 542 ms | 24724 KB |
test_07.txt | AC | 530 ms | 24096 KB |
test_08.txt | AC | 505 ms | 23940 KB |
test_09.txt | AC | 545 ms | 25368 KB |
test_10.txt | AC | 572 ms | 25680 KB |
test_11.txt | AC | 537 ms | 24536 KB |
test_12.txt | AC | 594 ms | 25284 KB |
test_13.txt | AC | 542 ms | 24240 KB |
test_14.txt | AC | 661 ms | 29460 KB |
test_15.txt | AC | 635 ms | 29840 KB |
test_16.txt | AC | 507 ms | 23852 KB |
test_17.txt | AC | 559 ms | 25592 KB |
test_18.txt | AC | 516 ms | 23904 KB |
test_19.txt | AC | 537 ms | 24240 KB |
test_20.txt | AC | 554 ms | 24740 KB |
test_21.txt | AC | 1286 ms | 43596 KB |
test_22.txt | AC | 1293 ms | 43880 KB |
test_23.txt | AC | 1270 ms | 44132 KB |
test_24.txt | AC | 1282 ms | 45272 KB |
test_25.txt | AC | 1277 ms | 45592 KB |
test_26.txt | AC | 1090 ms | 43220 KB |
test_27.txt | AC | 967 ms | 41160 KB |
test_28.txt | AC | 1287 ms | 42388 KB |
test_29.txt | AC | 467 ms | 23496 KB |
test_30.txt | AC | 486 ms | 23544 KB |
test_31.txt | AC | 925 ms | 36008 KB |
test_32.txt | AC | 508 ms | 23440 KB |
test_33.txt | AC | 1206 ms | 42780 KB |
test_34.txt | AC | 472 ms | 23424 KB |
test_35.txt | AC | 537 ms | 24084 KB |
test_36.txt | AC | 1278 ms | 43856 KB |
test_37.txt | AC | 1224 ms | 42664 KB |
test_38.txt | AC | 1219 ms | 43644 KB |
test_39.txt | AC | 1262 ms | 44492 KB |
test_40.txt | AC | 1335 ms | 45212 KB |
test_41.txt | AC | 1013 ms | 41460 KB |
test_42.txt | AC | 1006 ms | 41684 KB |
test_43.txt | AC | 994 ms | 41060 KB |