Submission #208769
Source Code Expand
import java.util.Arrays; import java.util.Collections; import java.util.Comparator; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int N = scan.nextInt(); Time[][] memoTimeArray = new Time[N][2]; for (int i = 0; i < N; i++) { String[] timeArray = scan.next().split("-"); memoTimeArray[i] = new Time[] { convertMin(timeArray[0], true), convertMin(timeArray[1], false) }; } scan.close(); Collections.sort(Arrays.asList(memoTimeArray), new Comparator<Time[]>() { @Override public int compare(Time[] o1, Time[] o2) { Time t1 = o1[0]; Time t2 = o2[0]; if (t1.getKey() > t2.getKey()) { return 1; } else if (t1.getKey() < t2.getKey()) { return -1; } else { return 0; } } }); Time startTime = memoTimeArray[0][0]; Time endTime = memoTimeArray[0][1]; for (int i = 1; i < memoTimeArray.length; i++) { Time[] timeArray = memoTimeArray[i]; if ((timeArray[0].getKey() >= startTime.getKey() && timeArray[0].getKey() <= endTime.getKey())) { if (timeArray[1].getKey() > endTime.getKey()) { endTime = timeArray[1]; } } else { System.out.println(startTime + "-" + endTime); startTime = timeArray[0]; endTime = timeArray[1]; } } System.out.println(startTime + "-" + endTime); } private static Time convertMin(String time, boolean isStart) { Integer hour = Integer.valueOf(time.substring(0, 2)); Integer min = Integer.valueOf(time.substring(2, 4)); if (isStart) { min = min / 5 * 5; } else { if (min % 5 != 0) { min = (min / 5 + 1) * 5; } } if (min >= 60) { min = min - 60; hour = hour + 1; } return new Time(hour, min); } public static class Time { int hour; int min; public Time(int hour, int min) { this.hour = hour; this.min = min; } public Integer getKey() { return (this.hour * 60 + this.min) / 5; } @Override public String toString() { return new StringBuilder().append(String.format("%02d", this.hour)).append(String.format("%02d", this.min)) .toString(); } } }
Submission Info
Submission Time | |
---|---|
Task | D - 感雨時刻の整理 |
User | penguinAAA |
Language | Java (OpenJDK 1.7.0) |
Score | 100 |
Code Size | 2792 Byte |
Status | AC |
Exec Time | 1178 ms |
Memory | 43568 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 | 478 ms | 22968 KB |
00_sample_02.txt | AC | 425 ms | 23064 KB |
00_sample_03.txt | AC | 431 ms | 23068 KB |
cho_cho_chokudai.txt | AC | 930 ms | 40428 KB |
chokudai_ga_cho.txt | AC | 912 ms | 40372 KB |
test_01.txt | AC | 491 ms | 24080 KB |
test_02.txt | AC | 495 ms | 24088 KB |
test_03.txt | AC | 495 ms | 24084 KB |
test_04.txt | AC | 485 ms | 24088 KB |
test_05.txt | AC | 499 ms | 24092 KB |
test_06.txt | AC | 465 ms | 23768 KB |
test_07.txt | AC | 450 ms | 23196 KB |
test_08.txt | AC | 444 ms | 23196 KB |
test_09.txt | AC | 510 ms | 25524 KB |
test_10.txt | AC | 514 ms | 25532 KB |
test_11.txt | AC | 486 ms | 24084 KB |
test_12.txt | AC | 482 ms | 23836 KB |
test_13.txt | AC | 474 ms | 23436 KB |
test_14.txt | AC | 515 ms | 25492 KB |
test_15.txt | AC | 517 ms | 25556 KB |
test_16.txt | AC | 460 ms | 23324 KB |
test_17.txt | AC | 510 ms | 25644 KB |
test_18.txt | AC | 466 ms | 23288 KB |
test_19.txt | AC | 491 ms | 23808 KB |
test_20.txt | AC | 498 ms | 24444 KB |
test_21.txt | AC | 1038 ms | 43264 KB |
test_22.txt | AC | 1038 ms | 43168 KB |
test_23.txt | AC | 1029 ms | 42684 KB |
test_24.txt | AC | 1094 ms | 43468 KB |
test_25.txt | AC | 1060 ms | 42732 KB |
test_26.txt | AC | 1178 ms | 43188 KB |
test_27.txt | AC | 1018 ms | 40732 KB |
test_28.txt | AC | 1029 ms | 43568 KB |
test_29.txt | AC | 429 ms | 22940 KB |
test_30.txt | AC | 441 ms | 23196 KB |
test_31.txt | AC | 706 ms | 33448 KB |
test_32.txt | AC | 435 ms | 23176 KB |
test_33.txt | AC | 1010 ms | 41644 KB |
test_34.txt | AC | 430 ms | 23064 KB |
test_35.txt | AC | 462 ms | 23704 KB |
test_36.txt | AC | 1060 ms | 42820 KB |
test_37.txt | AC | 1072 ms | 43212 KB |
test_38.txt | AC | 1060 ms | 42592 KB |
test_39.txt | AC | 985 ms | 42960 KB |
test_40.txt | AC | 1007 ms | 42944 KB |
test_41.txt | AC | 933 ms | 41704 KB |
test_42.txt | AC | 1067 ms | 41684 KB |
test_43.txt | AC | 914 ms | 41128 KB |