Submission #108517
Source Code Expand
import java.io.PrintWriter; import java.util.Arrays; import java.util.HashMap; import java.util.LinkedList; import java.util.PriorityQueue; import java.util.Scanner; import java.util.ArrayList; public class Main { public static class Time implements Comparable<Time>{ int start; int end; public Time(int start, int end) { super(); this.start = (start / 100) * 60 + (start % 100); this.end = (end / 100) * 60 + (end % 100); this.start = this.start / 5 * 5; this.end = this.end % 5 == 0 ? this.end / 5 * 5: (this.end / 5 + 1) * 5; } @Override public int compareTo(Time o) { if(this.start < o.start){ return -1; }else if(this.start > o.start){ return 1; }else if(this.end < o.end){ return -1; }else if(this.end > o.end){ return 1; }else{ return 0; } } @Override public String toString(){ String start_s_h = (start / 60) + ""; String start_s_m = (start % 60) + ""; String start_e_h = (end / 60) + ""; String start_e_m = (end % 60) + ""; return ((start_s_h.length() <= 1 ? "0" + start_s_h : start_s_h) + (start_s_m.length() <= 1 ? "0" + start_s_m : start_s_m) + "-" + (start_e_h.length() <= 1 ? "0" + start_e_h : start_e_h) + (start_e_m.length() <= 1 ? "0" + start_e_m : start_e_m)); } } public static void main(String args[]) { Scanner sc = new Scanner(System.in); final int N = sc.nextInt(); PriorityQueue<Time> queue = new PriorityQueue<Main.Time>(); for(int i = 0; i < N; i++){ String[] inputs = sc.next().split("-"); queue.add(new Time(Integer.parseInt(inputs[0]), Integer.parseInt(inputs[1]))); } //System.out.println(queue); LinkedList<Time> dic = new LinkedList<Main.Time>(); Time tmp = null; while(!queue.isEmpty()){ Time time = queue.poll(); //System.out.println(time); if(tmp == null){ tmp = time; continue; } if(tmp.end >= time.start){ if(tmp.end < time.end){ tmp.end = time.end; } continue; }else{ dic.add(tmp); tmp = time; } } if(tmp != null){ dic.add(tmp); } for(Time t : dic){ System.out.println(t); } } }
Submission Info
Submission Time | |
---|---|
Task | D - 感雨時刻の整理 |
User | mondatto |
Language | Java (OpenJDK 1.7.0) |
Score | 100 |
Code Size | 2290 Byte |
Status | AC |
Exec Time | 1031 ms |
Memory | 41172 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 | 473 ms | 23384 KB |
00_sample_02.txt | AC | 455 ms | 23524 KB |
00_sample_03.txt | AC | 462 ms | 23516 KB |
cho_cho_chokudai.txt | AC | 962 ms | 40376 KB |
chokudai_ga_cho.txt | AC | 951 ms | 40576 KB |
test_01.txt | AC | 471 ms | 23776 KB |
test_02.txt | AC | 477 ms | 23776 KB |
test_03.txt | AC | 488 ms | 23776 KB |
test_04.txt | AC | 511 ms | 23780 KB |
test_05.txt | AC | 510 ms | 23748 KB |
test_06.txt | AC | 489 ms | 24296 KB |
test_07.txt | AC | 476 ms | 23696 KB |
test_08.txt | AC | 481 ms | 23652 KB |
test_09.txt | AC | 680 ms | 24412 KB |
test_10.txt | AC | 554 ms | 24804 KB |
test_11.txt | AC | 540 ms | 24640 KB |
test_12.txt | AC | 508 ms | 24408 KB |
test_13.txt | AC | 486 ms | 23780 KB |
test_14.txt | AC | 529 ms | 24676 KB |
test_15.txt | AC | 536 ms | 24928 KB |
test_16.txt | AC | 503 ms | 23648 KB |
test_17.txt | AC | 548 ms | 24800 KB |
test_18.txt | AC | 529 ms | 23780 KB |
test_19.txt | AC | 537 ms | 24032 KB |
test_20.txt | AC | 537 ms | 24672 KB |
test_21.txt | AC | 1031 ms | 40564 KB |
test_22.txt | AC | 970 ms | 40228 KB |
test_23.txt | AC | 1007 ms | 40340 KB |
test_24.txt | AC | 987 ms | 39284 KB |
test_25.txt | AC | 998 ms | 39528 KB |
test_26.txt | AC | 982 ms | 40944 KB |
test_27.txt | AC | 930 ms | 39880 KB |
test_28.txt | AC | 997 ms | 40248 KB |
test_29.txt | AC | 468 ms | 23388 KB |
test_30.txt | AC | 489 ms | 23520 KB |
test_31.txt | AC | 689 ms | 28660 KB |
test_32.txt | AC | 474 ms | 23520 KB |
test_33.txt | AC | 964 ms | 39264 KB |
test_34.txt | AC | 468 ms | 23516 KB |
test_35.txt | AC | 507 ms | 24020 KB |
test_36.txt | AC | 981 ms | 40744 KB |
test_37.txt | AC | 941 ms | 41140 KB |
test_38.txt | AC | 950 ms | 39784 KB |
test_39.txt | AC | 977 ms | 41172 KB |
test_40.txt | AC | 996 ms | 40520 KB |
test_41.txt | AC | 965 ms | 40436 KB |
test_42.txt | AC | 986 ms | 40308 KB |
test_43.txt | AC | 974 ms | 40224 KB |