Submission #227446
Source Code Expand
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; import java.util.Comparator; import static java.lang.Integer.parseInt; public class Main { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String line = ""; while ((line = br.readLine()) != null && !line.isEmpty()) { int n = parseInt(line); int[][] memo = new int[n][2]; for (int i = 0; i < n; i++) { line = br.readLine(); memo[i][0] = parseInt(line.substring(0, 2)) * 100; memo[i][0] += parseInt(line.substring(2, 4)); memo[i][1] = parseInt(line.substring(5, 7)) * 100; memo[i][1] += parseInt(line.substring(7)) + 4; memo[i][0] /= 5; memo[i][0] *= 5; memo[i][1] /= 5; memo[i][1] *= 5; if (memo[i][1] % 100 == 60) { memo[i][1] += 40; } } Arrays.sort(memo, new Comparator<int[]>() { @Override public int compare(int[] o1, int[] o2) { if (o1[0] != o2[0]) { return o1[0] - o2[0]; } else { return o1[1] - o2[1]; } } }); int start = memo[0][0]; int end = memo[0][1]; for (int i = 1; i < n; i++) { if (memo[i][0] <= end) { if (memo[i][1] > end) { end = memo[i][1]; } } else { System.out.printf("%04d-%04d\n", start, end); start = memo[i][0]; end = memo[i][1]; } } System.out.printf("%04d-%04d\n", start, end); } } }
Submission Info
Submission Time | |
---|---|
Task | D - 感雨時刻の整理 |
User | sawfish |
Language | Java (OpenJDK 1.7.0) |
Score | 100 |
Code Size | 1554 Byte |
Status | AC |
Exec Time | 623 ms |
Memory | 35516 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 | 338 ms | 21208 KB |
00_sample_02.txt | AC | 338 ms | 21168 KB |
00_sample_03.txt | AC | 334 ms | 21172 KB |
cho_cho_chokudai.txt | AC | 484 ms | 33236 KB |
chokudai_ga_cho.txt | AC | 552 ms | 33708 KB |
test_01.txt | AC | 372 ms | 22192 KB |
test_02.txt | AC | 368 ms | 22320 KB |
test_03.txt | AC | 370 ms | 22320 KB |
test_04.txt | AC | 370 ms | 22320 KB |
test_05.txt | AC | 398 ms | 22324 KB |
test_06.txt | AC | 337 ms | 21296 KB |
test_07.txt | AC | 342 ms | 21300 KB |
test_08.txt | AC | 331 ms | 21276 KB |
test_09.txt | AC | 344 ms | 21940 KB |
test_10.txt | AC | 347 ms | 22048 KB |
test_11.txt | AC | 345 ms | 21428 KB |
test_12.txt | AC | 345 ms | 21296 KB |
test_13.txt | AC | 330 ms | 21296 KB |
test_14.txt | AC | 355 ms | 21940 KB |
test_15.txt | AC | 336 ms | 21936 KB |
test_16.txt | AC | 325 ms | 21300 KB |
test_17.txt | AC | 340 ms | 21300 KB |
test_18.txt | AC | 328 ms | 21296 KB |
test_19.txt | AC | 333 ms | 21296 KB |
test_20.txt | AC | 345 ms | 21428 KB |
test_21.txt | AC | 605 ms | 35416 KB |
test_22.txt | AC | 550 ms | 35328 KB |
test_23.txt | AC | 557 ms | 35320 KB |
test_24.txt | AC | 554 ms | 35392 KB |
test_25.txt | AC | 570 ms | 35516 KB |
test_26.txt | AC | 565 ms | 35084 KB |
test_27.txt | AC | 527 ms | 33728 KB |
test_28.txt | AC | 567 ms | 34980 KB |
test_29.txt | AC | 327 ms | 21300 KB |
test_30.txt | AC | 345 ms | 21300 KB |
test_31.txt | AC | 475 ms | 27544 KB |
test_32.txt | AC | 334 ms | 21172 KB |
test_33.txt | AC | 528 ms | 32992 KB |
test_34.txt | AC | 336 ms | 21156 KB |
test_35.txt | AC | 340 ms | 21300 KB |
test_36.txt | AC | 556 ms | 35260 KB |
test_37.txt | AC | 585 ms | 35060 KB |
test_38.txt | AC | 623 ms | 35380 KB |
test_39.txt | AC | 591 ms | 35268 KB |
test_40.txt | AC | 564 ms | 35300 KB |
test_41.txt | AC | 482 ms | 32520 KB |
test_42.txt | AC | 566 ms | 35048 KB |
test_43.txt | AC | 487 ms | 32944 KB |