Submission #4575883
Source Code Expand
import java.util.*; public class Main { private static class pair implements Comparable<pair> { private final int left; private final int right; public pair(int left, int right) { this.left = left; this.right = right; } public int compareTo(pair p) { if (left > p.left) return 1; else if (left < p.left) return -1; else { if (right > p.right) return 1; else if (right < p.right) return -1; else return 0; } } } public static String time(int t) { StringBuffer ans = new StringBuffer(); ans.append(String.valueOf(t)); int n = ans.length(); if (n != 4) { StringBuffer tmp = new StringBuffer(); for (int i = 0; i < 4 - n; ++i) { tmp.append("0"); } ans.insert(0, tmp); } return ans.toString(); } public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); pair st[] = new pair[n + 1]; for (int i = 0; i < n; ++i) { String tmp = sc.next(); int s = Integer.parseInt(tmp.substring(0, 4)); int r = s % 5; s -= r; int e = Integer.parseInt(tmp.substring(5)); r = e % 5; if (r != 0) { int tmpr = e % 100; if (tmpr > 55 && tmpr <= 59) { r = 100 - tmpr; } else r = 5 - r; } e += r; st[i] = new pair(s, e); } sc.close(); st[n] = new pair(2401, 0); Arrays.sort(st); String ans = ""; int max = 0; for (int i = 0; i < n; ++i) { if (ans.length() < 1) { ans = time(st[i].left) + "-"; } if (max == 0) max = st[i].right; if (max >= st[i + 1].left) { max = Math.max(max, st[i].right); max = Math.max(max, st[i + 1].right); } else { ans += time(max); System.out.println(ans); ans = ""; max = 0; } } } }
Submission Info
Submission Time | |
---|---|
Task | D - 感雨時刻の整理 |
User | t_tomo |
Language | Java7 (OpenJDK 1.7.0) |
Score | 100 |
Code Size | 1839 Byte |
Status | AC |
Exec Time | 655 ms |
Memory | 44884 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 | 100 ms | 20436 KB |
00_sample_02.txt | AC | 103 ms | 19028 KB |
00_sample_03.txt | AC | 99 ms | 18900 KB |
cho_cho_chokudai.txt | AC | 470 ms | 38828 KB |
chokudai_ga_cho.txt | AC | 595 ms | 43080 KB |
test_01.txt | AC | 118 ms | 21332 KB |
test_02.txt | AC | 118 ms | 21076 KB |
test_03.txt | AC | 117 ms | 19284 KB |
test_04.txt | AC | 126 ms | 21204 KB |
test_05.txt | AC | 116 ms | 19284 KB |
test_06.txt | AC | 128 ms | 21460 KB |
test_07.txt | AC | 121 ms | 20948 KB |
test_08.txt | AC | 107 ms | 20820 KB |
test_09.txt | AC | 139 ms | 19796 KB |
test_10.txt | AC | 151 ms | 23636 KB |
test_11.txt | AC | 148 ms | 19924 KB |
test_12.txt | AC | 129 ms | 21844 KB |
test_13.txt | AC | 116 ms | 21332 KB |
test_14.txt | AC | 148 ms | 19924 KB |
test_15.txt | AC | 152 ms | 22228 KB |
test_16.txt | AC | 123 ms | 22868 KB |
test_17.txt | AC | 146 ms | 21588 KB |
test_18.txt | AC | 115 ms | 21204 KB |
test_19.txt | AC | 130 ms | 19796 KB |
test_20.txt | AC | 144 ms | 21588 KB |
test_21.txt | AC | 600 ms | 41352 KB |
test_22.txt | AC | 650 ms | 44300 KB |
test_23.txt | AC | 640 ms | 44884 KB |
test_24.txt | AC | 576 ms | 43072 KB |
test_25.txt | AC | 594 ms | 42728 KB |
test_26.txt | AC | 561 ms | 43012 KB |
test_27.txt | AC | 555 ms | 42424 KB |
test_28.txt | AC | 653 ms | 43960 KB |
test_29.txt | AC | 102 ms | 22868 KB |
test_30.txt | AC | 105 ms | 20948 KB |
test_31.txt | AC | 304 ms | 31300 KB |
test_32.txt | AC | 103 ms | 18900 KB |
test_33.txt | AC | 580 ms | 36772 KB |
test_34.txt | AC | 102 ms | 22740 KB |
test_35.txt | AC | 123 ms | 21588 KB |
test_36.txt | AC | 655 ms | 42524 KB |
test_37.txt | AC | 650 ms | 38928 KB |
test_38.txt | AC | 621 ms | 40684 KB |
test_39.txt | AC | 611 ms | 42664 KB |
test_40.txt | AC | 629 ms | 43436 KB |
test_41.txt | AC | 471 ms | 43596 KB |
test_42.txt | AC | 642 ms | 42976 KB |
test_43.txt | AC | 503 ms | 43080 KB |