Submission #191046
Source Code Expand
import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.Arrays; import java.util.Comparator; public class Main { static int toFmIndex(int t) { return (t / 100) * 12 + (t % 100) / 5; } static String fromFmIndex(int i) { return String.format("%02d%02d", i / 12, (i % 12) * 5); } static int[] toRange(String s) { String[] ts = s.split("-"); int from = Integer.parseInt(ts[0], 10); int to = Integer.parseInt(ts[1], 10) + 4; return new int[]{toFmIndex(from), toFmIndex(to)}; } static void print(int f,int t){ System.out.println(fromFmIndex(f) + "-" + fromFmIndex(t)); } static void solve() throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int n = Integer.parseInt(br.readLine(), 10); int[][] times = new int[n][]; for (int i = 0; i < n; i++) times[i] = toRange(br.readLine()); Arrays.sort(times, new Comparator<int[]>() { @Override public int compare(int[] o1, int[] o2) { return o1[0] != o2[0] ? (o1[0] - o2[0]) : (o1[1] - o2[1]); } }); int from = -1, to = -1; for (int i = 0; i < n; i++){ boolean p = to>=0&×[i][0]>to; // print boolean u = from<0||p; // update from if(p)print(from,to); if(u)from = times[i][0]; to = Math.max(to,times[i][1]); } if(to>=0)print(from,to); } public static void main(String... args) throws Exception { solve(); } }
Submission Info
Submission Time | |
---|---|
Task | D - 感雨時刻の整理 |
User | dolpen |
Language | Java (OpenJDK 1.7.0) |
Score | 100 |
Code Size | 1692 Byte |
Status | AC |
Exec Time | 764 ms |
Memory | 34296 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 | 402 ms | 19104 KB |
00_sample_02.txt | AC | 365 ms | 19144 KB |
00_sample_03.txt | AC | 462 ms | 19116 KB |
cho_cho_chokudai.txt | AC | 629 ms | 32044 KB |
chokudai_ga_cho.txt | AC | 649 ms | 32456 KB |
test_01.txt | AC | 415 ms | 20524 KB |
test_02.txt | AC | 411 ms | 20520 KB |
test_03.txt | AC | 411 ms | 20648 KB |
test_04.txt | AC | 412 ms | 20648 KB |
test_05.txt | AC | 414 ms | 20644 KB |
test_06.txt | AC | 384 ms | 19220 KB |
test_07.txt | AC | 373 ms | 19204 KB |
test_08.txt | AC | 368 ms | 19180 KB |
test_09.txt | AC | 385 ms | 20136 KB |
test_10.txt | AC | 392 ms | 20136 KB |
test_11.txt | AC | 384 ms | 20004 KB |
test_12.txt | AC | 383 ms | 20132 KB |
test_13.txt | AC | 365 ms | 19068 KB |
test_14.txt | AC | 390 ms | 19876 KB |
test_15.txt | AC | 388 ms | 20000 KB |
test_16.txt | AC | 368 ms | 19112 KB |
test_17.txt | AC | 473 ms | 20008 KB |
test_18.txt | AC | 375 ms | 19108 KB |
test_19.txt | AC | 378 ms | 20008 KB |
test_20.txt | AC | 376 ms | 19880 KB |
test_21.txt | AC | 668 ms | 32696 KB |
test_22.txt | AC | 691 ms | 33140 KB |
test_23.txt | AC | 731 ms | 34296 KB |
test_24.txt | AC | 746 ms | 33736 KB |
test_25.txt | AC | 750 ms | 32908 KB |
test_26.txt | AC | 674 ms | 33144 KB |
test_27.txt | AC | 622 ms | 31672 KB |
test_28.txt | AC | 688 ms | 32760 KB |
test_29.txt | AC | 365 ms | 19112 KB |
test_30.txt | AC | 369 ms | 19112 KB |
test_31.txt | AC | 533 ms | 26504 KB |
test_32.txt | AC | 369 ms | 19112 KB |
test_33.txt | AC | 683 ms | 32588 KB |
test_34.txt | AC | 363 ms | 19100 KB |
test_35.txt | AC | 420 ms | 19232 KB |
test_36.txt | AC | 636 ms | 32656 KB |
test_37.txt | AC | 677 ms | 33028 KB |
test_38.txt | AC | 676 ms | 33040 KB |
test_39.txt | AC | 690 ms | 32772 KB |
test_40.txt | AC | 764 ms | 33200 KB |
test_41.txt | AC | 605 ms | 31684 KB |
test_42.txt | AC | 686 ms | 32708 KB |
test_43.txt | AC | 732 ms | 31744 KB |