Submission #841047
Source Code Expand
import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); // 入力を取得 int count = sc.nextInt(); List<String> records = new ArrayList<>(); for (int i = 0; i < count; i++) { records.add(sc.next()); } // 入力時刻を丸める for (int i = 0; i < count; i++) { String[] orgTime = records.get(i).split("-"); // 開始時刻を丸める int startTime = Integer.parseInt(orgTime[0]); int startMin = startTime % 10; if (0 < startMin && startMin < 5) { startTime = startTime / 10 * 10; } else if (5 < startMin && startMin < 10) { startTime = startTime / 10 * 10 + 5; } // 終了時刻を丸める int endTime = Integer.parseInt(orgTime[1]); int endMin = endTime % 10; if (0 < endMin && endMin < 5) { endTime = endTime / 10 * 10 + 5; } else if (5 < endMin && endMin < 10) { endTime = endTime / 10 * 10 + 10; if (endTime % 100 == 60) { endTime = endTime + 40; } } records.set(i, String.format("%04d", startTime) + "-" + String.format("%04d", endTime)); } // ソート Collections.sort(records); // 継続している時刻を結合 List<Boolean> outputFlg = new ArrayList<>(); for (int i = 0; i < count; i++) { outputFlg.add(true); } for (int i = 0; i < count - 1; i++) { // 結合済みの場合はチェックしない if (!outputFlg.get(i)) { continue; } String[] orgTime = records.get(i).split("-"); for (int j = i + 1; j < count; j++) { String[] trgTime = records.get(j).split("-"); if (trgTime[0].compareTo(orgTime[1]) <= 0) { if (orgTime[1].compareTo(trgTime[1]) < 0) { orgTime[1] = trgTime[1]; } outputFlg.set(j, false); } } records.set(i, orgTime[0] + "-" + orgTime[1]); } // 出力 for (int i = 0; i < count; i++) { if (outputFlg.get(i)) { System.out.println(records.get(i)); } } sc.close(); } }
Submission Info
Submission Time | |
---|---|
Task | D - 感雨時刻の整理 |
User | toypuchi |
Language | Java (OpenJDK 1.7.0) |
Score | 100 |
Code Size | 2147 Byte |
Status | AC |
Exec Time | 1888 ms |
Memory | 48864 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 | 384 ms | 23212 KB |
00_sample_02.txt | AC | 377 ms | 23228 KB |
00_sample_03.txt | AC | 384 ms | 23196 KB |
cho_cho_chokudai.txt | AC | 1577 ms | 45604 KB |
chokudai_ga_cho.txt | AC | 1621 ms | 45332 KB |
test_01.txt | AC | 587 ms | 31012 KB |
test_02.txt | AC | 601 ms | 31384 KB |
test_03.txt | AC | 586 ms | 31016 KB |
test_04.txt | AC | 612 ms | 30884 KB |
test_05.txt | AC | 593 ms | 31092 KB |
test_06.txt | AC | 446 ms | 24244 KB |
test_07.txt | AC | 428 ms | 24152 KB |
test_08.txt | AC | 426 ms | 23784 KB |
test_09.txt | AC | 584 ms | 30392 KB |
test_10.txt | AC | 606 ms | 29944 KB |
test_11.txt | AC | 565 ms | 28592 KB |
test_12.txt | AC | 525 ms | 25696 KB |
test_13.txt | AC | 451 ms | 24124 KB |
test_14.txt | AC | 572 ms | 29740 KB |
test_15.txt | AC | 586 ms | 30212 KB |
test_16.txt | AC | 433 ms | 24072 KB |
test_17.txt | AC | 578 ms | 30376 KB |
test_18.txt | AC | 454 ms | 24072 KB |
test_19.txt | AC | 534 ms | 26640 KB |
test_20.txt | AC | 556 ms | 27584 KB |
test_21.txt | AC | 1874 ms | 48632 KB |
test_22.txt | AC | 1855 ms | 48752 KB |
test_23.txt | AC | 1631 ms | 46028 KB |
test_24.txt | AC | 1636 ms | 45868 KB |
test_25.txt | AC | 1699 ms | 45752 KB |
test_26.txt | AC | 1650 ms | 45580 KB |
test_27.txt | AC | 1589 ms | 46284 KB |
test_28.txt | AC | 1831 ms | 46284 KB |
test_29.txt | AC | 515 ms | 23204 KB |
test_30.txt | AC | 411 ms | 23520 KB |
test_31.txt | AC | 1190 ms | 40928 KB |
test_32.txt | AC | 492 ms | 23376 KB |
test_33.txt | AC | 1600 ms | 44372 KB |
test_34.txt | AC | 377 ms | 23184 KB |
test_35.txt | AC | 485 ms | 24864 KB |
test_36.txt | AC | 1645 ms | 45560 KB |
test_37.txt | AC | 1815 ms | 48864 KB |
test_38.txt | AC | 1888 ms | 48496 KB |
test_39.txt | AC | 1713 ms | 46292 KB |
test_40.txt | AC | 1752 ms | 48236 KB |
test_41.txt | AC | 1573 ms | 45956 KB |
test_42.txt | AC | 1663 ms | 47448 KB |
test_43.txt | AC | 1638 ms | 48748 KB |