Submission #1003967
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 n = sc.nextInt(); List<String> arrayOfRange = new ArrayList<String>(); for (int i = 0; i < n; i++) { arrayOfRange.add(roundTimeRange(sc.next())); } Collections.sort(arrayOfRange); arrangeRange(arrayOfRange); } private static void arrangeRange(List<String> arrayOfRange) { String prev_start = null; String prev_end = null; for (int i = 0; i < arrayOfRange.size(); i++) { String current = (String)arrayOfRange.get(i); String current_start = current.substring(0, current.indexOf('-')); String current_end = current.substring(current.indexOf('-') + 1); if (i == 0) { prev_start = current_start; prev_end = current_end; } else { if (current_start.compareTo(prev_end) <= 0) { if (prev_end.compareTo(current_end) <= 0) { prev_end = current_end; } } else { System.out.println(prev_start + "-" + prev_end); prev_start = current_start; prev_end = current_end; } } } System.out.println(prev_start + "-" + prev_end); } private static String roundTimeRange(String range) { String start = range.substring(0, range.indexOf('-')); String end = range.substring(range.indexOf('-') + 1); start = roundDownTime(start); end = roundUpTime(end); return start + "-" + end; } private static String roundUpTime(String time) { int hour = Integer.parseInt(time.substring(0, 2)); int minutes = Integer.parseInt(time.substring(2, 4)); if (minutes % 5 != 0) { minutes = minutes + (5 - minutes % 5); if (minutes == 60) { minutes = 0; hour = hour + 1; } } return String.format("%02d", hour) + String.format("%02d", minutes); } private static String roundDownTime(String time) { int minutes = Integer.parseInt(time.substring(2, 4)); minutes = minutes - minutes % 5; return time.substring(0, 2) + String.format("%02d", minutes); } }
Submission Info
Submission Time | |
---|---|
Task | D - 感雨時刻の整理 |
User | taikyokuken |
Language | Java (OpenJDK 1.7.0) |
Score | 100 |
Code Size | 2177 Byte |
Status | AC |
Exec Time | 1164 ms |
Memory | 46448 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 | 233 ms | 14444 KB |
00_sample_02.txt | AC | 214 ms | 14292 KB |
00_sample_03.txt | AC | 214 ms | 14328 KB |
cho_cho_chokudai.txt | AC | 1054 ms | 45100 KB |
chokudai_ga_cho.txt | AC | 1149 ms | 46448 KB |
test_01.txt | AC | 252 ms | 15152 KB |
test_02.txt | AC | 253 ms | 15200 KB |
test_03.txt | AC | 260 ms | 15144 KB |
test_04.txt | AC | 256 ms | 15132 KB |
test_05.txt | AC | 255 ms | 15232 KB |
test_06.txt | AC | 283 ms | 16864 KB |
test_07.txt | AC | 256 ms | 15264 KB |
test_08.txt | AC | 241 ms | 15152 KB |
test_09.txt | AC | 392 ms | 21016 KB |
test_10.txt | AC | 401 ms | 20672 KB |
test_11.txt | AC | 367 ms | 20988 KB |
test_12.txt | AC | 329 ms | 19196 KB |
test_13.txt | AC | 261 ms | 15444 KB |
test_14.txt | AC | 374 ms | 20648 KB |
test_15.txt | AC | 404 ms | 21156 KB |
test_16.txt | AC | 257 ms | 15332 KB |
test_17.txt | AC | 371 ms | 20992 KB |
test_18.txt | AC | 274 ms | 15508 KB |
test_19.txt | AC | 336 ms | 19336 KB |
test_20.txt | AC | 365 ms | 20292 KB |
test_21.txt | AC | 1103 ms | 45908 KB |
test_22.txt | AC | 1128 ms | 44592 KB |
test_23.txt | AC | 1139 ms | 46360 KB |
test_24.txt | AC | 1093 ms | 45380 KB |
test_25.txt | AC | 1108 ms | 43656 KB |
test_26.txt | AC | 1164 ms | 45168 KB |
test_27.txt | AC | 1153 ms | 44864 KB |
test_28.txt | AC | 1161 ms | 46252 KB |
test_29.txt | AC | 214 ms | 14324 KB |
test_30.txt | AC | 226 ms | 14680 KB |
test_31.txt | AC | 807 ms | 38404 KB |
test_32.txt | AC | 218 ms | 14536 KB |
test_33.txt | AC | 1057 ms | 44284 KB |
test_34.txt | AC | 208 ms | 14420 KB |
test_35.txt | AC | 287 ms | 17352 KB |
test_36.txt | AC | 1146 ms | 45044 KB |
test_37.txt | AC | 1157 ms | 44500 KB |
test_38.txt | AC | 1113 ms | 46148 KB |
test_39.txt | AC | 1139 ms | 44596 KB |
test_40.txt | AC | 1163 ms | 44764 KB |
test_41.txt | AC | 1105 ms | 45108 KB |
test_42.txt | AC | 1126 ms | 44652 KB |
test_43.txt | AC | 1069 ms | 45516 KB |