Submission #110418
Source Code Expand
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; public class Main { private static BufferedReader br = null; private static RecordCmp cp = null; static { br = new BufferedReader(new InputStreamReader(System.in)); cp = new RecordCmp(); } /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub ArrayList<Record> dat = new ArrayList<Record>(); String out = ""; int cnt = parseCnt(); int stk = 0; for (int i = 0; i < cnt; i++) { Record[] rng = parseRange(); dat.add(rng[0]); dat.add(rng[1]); } Collections.sort(dat, cp); for (int i = 0; i < cnt*2; i++) { Record rec = dat.get(i); if (rec.k == 1) { if (stk++==0) { out = String.format("%04d-", rec.t); } } else { stk--; } if (stk == 0) { out += String.format("%04d", rec.t); System.out.println(out); } } } private static Record[] parseRange() { Record[] rng = null; String str = null; if ((str = parseStdin()) != null) { String[] line = str.split("-"); int tmp1 = Integer.parseInt(line[0]); int tmp2 = Integer.parseInt(line[1]); tmp1 = (tmp1/100)*60 + tmp1%100; tmp2 = (tmp2/100)*60 + tmp2%100; tmp1 = (tmp1/5)*5; tmp2 = (tmp2/5+(((tmp2%5)>0)?1:0))*5; rng = new Record[2]; rng[0] = new Record(); rng[0].t = ((tmp1)/60)*100+((tmp1)%60); rng[0].k = 1; rng[1] = new Record(); rng[1].t = ((tmp2)/60)*100+((tmp2)%60); rng[1].k = 2; } return rng; } private static int parseCnt() { int cnt = 0; String str = null; if ((str = parseStdin()) != null) { cnt = Integer.parseInt(str); } return cnt; } private static String parseStdin() { String stdin = null; try { String tmp = br.readLine(); if (tmp != null) { if (!tmp.isEmpty()) stdin = tmp; } } catch (IOException e) {} return stdin; } private static class Record { public int t; public int k; } private static class RecordCmp implements Comparator<Record> { public int compare(Record o1, Record o2) { // TODO 自動生成されたメソッド・スタブ return (o1.t!=o2.t)?o1.t-o2.t:o1.k-o2.k; } } }
Submission Info
Submission Time | |
---|---|
Task | D - 感雨時刻の整理 |
User | aramaki |
Language | Java (OpenJDK 1.7.0) |
Score | 100 |
Code Size | 2431 Byte |
Status | AC |
Exec Time | 799 ms |
Memory | 36044 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 | 441 ms | 21244 KB |
00_sample_02.txt | AC | 407 ms | 21300 KB |
00_sample_03.txt | AC | 403 ms | 21208 KB |
cho_cho_chokudai.txt | AC | 739 ms | 35468 KB |
chokudai_ga_cho.txt | AC | 772 ms | 35496 KB |
test_01.txt | AC | 461 ms | 22352 KB |
test_02.txt | AC | 439 ms | 22364 KB |
test_03.txt | AC | 432 ms | 22232 KB |
test_04.txt | AC | 444 ms | 22364 KB |
test_05.txt | AC | 473 ms | 22368 KB |
test_06.txt | AC | 419 ms | 21336 KB |
test_07.txt | AC | 430 ms | 21216 KB |
test_08.txt | AC | 410 ms | 21332 KB |
test_09.txt | AC | 438 ms | 22492 KB |
test_10.txt | AC | 446 ms | 22364 KB |
test_11.txt | AC | 427 ms | 22240 KB |
test_12.txt | AC | 435 ms | 22240 KB |
test_13.txt | AC | 427 ms | 21332 KB |
test_14.txt | AC | 434 ms | 22104 KB |
test_15.txt | AC | 449 ms | 22360 KB |
test_16.txt | AC | 415 ms | 21344 KB |
test_17.txt | AC | 434 ms | 22224 KB |
test_18.txt | AC | 412 ms | 21344 KB |
test_19.txt | AC | 443 ms | 22104 KB |
test_20.txt | AC | 438 ms | 22236 KB |
test_21.txt | AC | 756 ms | 35456 KB |
test_22.txt | AC | 775 ms | 34176 KB |
test_23.txt | AC | 760 ms | 35036 KB |
test_24.txt | AC | 762 ms | 34668 KB |
test_25.txt | AC | 778 ms | 35348 KB |
test_26.txt | AC | 753 ms | 34976 KB |
test_27.txt | AC | 766 ms | 35252 KB |
test_28.txt | AC | 799 ms | 35368 KB |
test_29.txt | AC | 409 ms | 21208 KB |
test_30.txt | AC | 426 ms | 21328 KB |
test_31.txt | AC | 556 ms | 28748 KB |
test_32.txt | AC | 405 ms | 21204 KB |
test_33.txt | AC | 758 ms | 36044 KB |
test_34.txt | AC | 449 ms | 21340 KB |
test_35.txt | AC | 416 ms | 21336 KB |
test_36.txt | AC | 769 ms | 34484 KB |
test_37.txt | AC | 779 ms | 35732 KB |
test_38.txt | AC | 767 ms | 34384 KB |
test_39.txt | AC | 768 ms | 34664 KB |
test_40.txt | AC | 777 ms | 34880 KB |
test_41.txt | AC | 716 ms | 34836 KB |
test_42.txt | AC | 764 ms | 35936 KB |
test_43.txt | AC | 723 ms | 33544 KB |