Submission #173237
Source Code Expand
import java.util.Arrays; import java.util.Comparator; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); Memo[] memos = new Memo[n]; for (int i = 0; i < n; i++) { memos[i] = new Memo(sc.next()); } Arrays.sort(memos, new MemoComparator()); int stime = Integer.MAX_VALUE; int etime = Integer.MAX_VALUE; for (int i = 0; i < n;) { if (stime > memos[i].s) { stime = memos[i].s; etime = memos[i].e; i++; } else if (etime < memos[i].s) { System.out.println(String.format("%04d-%04d", stime, etime)); stime = Integer.MAX_VALUE; etime = Integer.MAX_VALUE; } else if (etime >= memos[i].e) { i++; } else if (etime < memos[i].e) { etime = memos[i].e; i++; } else { assert true; } } System.out.println(String.format("%04d-%04d", stime, etime)); sc.close(); } private static class Memo { int s; int e; Memo(String memo) { // StringBuffer str = new StringBuffer(memo); // str.setCharAt(4, ' '); // Scanner sc = new Scanner(str.toString()); // // s = sc.nextInt(); // e = sc.nextInt(); s = (memo.charAt(0) - '0') * 1000 + (memo.charAt(1) - '0') * 100 + (memo.charAt(2) - '0') * 10 + (memo.charAt(3) - '0') * 1; e = (memo.charAt(5) - '0') * 1000 + (memo.charAt(6) - '0') * 100 + (memo.charAt(7) - '0') * 10 + (memo.charAt(8) - '0') * 1; s -= s % 5; e += e % 5 > 0 ? 5 - e % 5 : 0; if (e % 100 == 60) { e += 40; } // sc.close(); } } private static class MemoComparator implements Comparator<Memo>{ @Override public int compare(Memo memo1, Memo memo2) { return memo1.s - memo2.s; } } }
Submission Info
Submission Time | |
---|---|
Task | D - 感雨時刻の整理 |
User | garnacha |
Language | Java (OpenJDK 1.7.0) |
Score | 100 |
Code Size | 1835 Byte |
Status | AC |
Exec Time | 915 ms |
Memory | 38116 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 | 450 ms | 20444 KB |
00_sample_02.txt | AC | 432 ms | 20432 KB |
00_sample_03.txt | AC | 427 ms | 20380 KB |
cho_cho_chokudai.txt | AC | 712 ms | 34268 KB |
chokudai_ga_cho.txt | AC | 704 ms | 35348 KB |
test_01.txt | AC | 466 ms | 20896 KB |
test_02.txt | AC | 459 ms | 20908 KB |
test_03.txt | AC | 454 ms | 20844 KB |
test_04.txt | AC | 450 ms | 20800 KB |
test_05.txt | AC | 464 ms | 20944 KB |
test_06.txt | AC | 450 ms | 20824 KB |
test_07.txt | AC | 440 ms | 20492 KB |
test_08.txt | AC | 422 ms | 20440 KB |
test_09.txt | AC | 449 ms | 21172 KB |
test_10.txt | AC | 477 ms | 23496 KB |
test_11.txt | AC | 464 ms | 21208 KB |
test_12.txt | AC | 464 ms | 20960 KB |
test_13.txt | AC | 437 ms | 20548 KB |
test_14.txt | AC | 469 ms | 23708 KB |
test_15.txt | AC | 462 ms | 21464 KB |
test_16.txt | AC | 432 ms | 20560 KB |
test_17.txt | AC | 476 ms | 21328 KB |
test_18.txt | AC | 432 ms | 20568 KB |
test_19.txt | AC | 463 ms | 20968 KB |
test_20.txt | AC | 461 ms | 21216 KB |
test_21.txt | AC | 796 ms | 36396 KB |
test_22.txt | AC | 793 ms | 37088 KB |
test_23.txt | AC | 863 ms | 37152 KB |
test_24.txt | AC | 786 ms | 36104 KB |
test_25.txt | AC | 853 ms | 37116 KB |
test_26.txt | AC | 889 ms | 36976 KB |
test_27.txt | AC | 810 ms | 35196 KB |
test_28.txt | AC | 878 ms | 37888 KB |
test_29.txt | AC | 414 ms | 20432 KB |
test_30.txt | AC | 443 ms | 20448 KB |
test_31.txt | AC | 582 ms | 26220 KB |
test_32.txt | AC | 422 ms | 20448 KB |
test_33.txt | AC | 837 ms | 36332 KB |
test_34.txt | AC | 443 ms | 20312 KB |
test_35.txt | AC | 603 ms | 20816 KB |
test_36.txt | AC | 873 ms | 37036 KB |
test_37.txt | AC | 906 ms | 38116 KB |
test_38.txt | AC | 915 ms | 36340 KB |
test_39.txt | AC | 886 ms | 37380 KB |
test_40.txt | AC | 894 ms | 35760 KB |
test_41.txt | AC | 762 ms | 35080 KB |
test_42.txt | AC | 853 ms | 37032 KB |
test_43.txt | AC | 732 ms | 35808 KB |