Submission #353578
Source Code Expand
import java.util.Scanner; import java.util.Arrays; class Main{ public static void main(String[] args){ Scanner sca = new Scanner(System.in); final int N = sca.nextInt(); sca.useDelimiter("\\D+"); Data[] datas = new Data[N]; //降水時間の読み込み for(int i= 0, s, e; i < N; i++){ s = sca.nextInt(); s -= s % 100 % 5; e = sca.nextInt() + 4; e -= e % 100 % 5; if(e % 100 == 60) e += 40; datas[i] = new Data(s, e); } Arrays.sort(datas); StringBuilder buf = new StringBuilder();//文字列連結用 for(int i = 0; i < N; i++){ if(i == N-1 || datas[i].getEnd() < datas[i+1].getStart()){ buf.append(String.format("%1$04d", datas[i].getStart())); buf.append("-"); buf.append(String.format("%1$04d", datas[i].getEnd())); System.out.println(buf.toString()); buf.setLength(0); }else{ datas[i+1].setStart(datas[i].getStart()); if(datas[i].getEnd() > datas[i+1].getEnd()) datas[i+1].setEnd(datas[i].getEnd()); } } } } class Data implements Comparable<Data>{ private int start; private int end; public Data(int s, int e){ this.start = s; this.end = e; } public int getStart(){ return this.start; } public int getEnd(){ return this.end; } public void setStart(int s){ this.start = s; } public void setEnd(int e){ this.end = e; } //startで比較するソート用メソッド public int compareTo(Data nextD){ return this.getStart() - nextD.getStart(); } }
Submission Info
Submission Time | |
---|---|
Task | D - 感雨時刻の整理 |
User | taiki |
Language | Java (OpenJDK 1.7.0) |
Score | 100 |
Code Size | 1559 Byte |
Status | AC |
Exec Time | 967 ms |
Memory | 37356 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 | 467 ms | 22728 KB |
00_sample_02.txt | AC | 467 ms | 22708 KB |
00_sample_03.txt | AC | 465 ms | 22708 KB |
cho_cho_chokudai.txt | AC | 823 ms | 36924 KB |
chokudai_ga_cho.txt | AC | 837 ms | 36980 KB |
test_01.txt | AC | 520 ms | 23756 KB |
test_02.txt | AC | 505 ms | 23880 KB |
test_03.txt | AC | 506 ms | 23804 KB |
test_04.txt | AC | 512 ms | 23724 KB |
test_05.txt | AC | 509 ms | 23904 KB |
test_06.txt | AC | 487 ms | 23576 KB |
test_07.txt | AC | 486 ms | 23348 KB |
test_08.txt | AC | 479 ms | 23316 KB |
test_09.txt | AC | 545 ms | 24500 KB |
test_10.txt | AC | 542 ms | 24700 KB |
test_11.txt | AC | 520 ms | 24052 KB |
test_12.txt | AC | 514 ms | 23996 KB |
test_13.txt | AC | 487 ms | 23612 KB |
test_14.txt | AC | 528 ms | 24456 KB |
test_15.txt | AC | 553 ms | 24756 KB |
test_16.txt | AC | 485 ms | 23592 KB |
test_17.txt | AC | 543 ms | 24412 KB |
test_18.txt | AC | 490 ms | 23548 KB |
test_19.txt | AC | 517 ms | 24040 KB |
test_20.txt | AC | 518 ms | 23956 KB |
test_21.txt | AC | 967 ms | 37292 KB |
test_22.txt | AC | 887 ms | 36588 KB |
test_23.txt | AC | 951 ms | 37332 KB |
test_24.txt | AC | 942 ms | 36292 KB |
test_25.txt | AC | 901 ms | 36628 KB |
test_26.txt | AC | 900 ms | 36816 KB |
test_27.txt | AC | 865 ms | 36984 KB |
test_28.txt | AC | 943 ms | 37060 KB |
test_29.txt | AC | 455 ms | 22708 KB |
test_30.txt | AC | 476 ms | 23184 KB |
test_31.txt | AC | 723 ms | 34068 KB |
test_32.txt | AC | 484 ms | 23120 KB |
test_33.txt | AC | 933 ms | 36260 KB |
test_34.txt | AC | 507 ms | 22700 KB |
test_35.txt | AC | 508 ms | 23656 KB |
test_36.txt | AC | 936 ms | 36708 KB |
test_37.txt | AC | 916 ms | 36144 KB |
test_38.txt | AC | 913 ms | 37160 KB |
test_39.txt | AC | 903 ms | 37356 KB |
test_40.txt | AC | 899 ms | 36816 KB |
test_41.txt | AC | 827 ms | 36760 KB |
test_42.txt | AC | 937 ms | 37032 KB |
test_43.txt | AC | 830 ms | 36732 KB |