Submission #731649
Source Code Expand
import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.util.List; import java.util.NoSuchElementException; public class Main { private static class T { public int start; public int end; } public static void main(String[] args) { FastScanner sc = new FastScanner(); int N = sc.nextInt(); List<T> list = new ArrayList<>(); for (int i = 0; i < N; i ++) { String[] elem = sc.next().split("-"); int S = Integer.parseInt(elem[0]); int E = Integer.parseInt(elem[1]); T t = new T(); t.start = S / 100 * 60 + S % 100; t.end = E / 100 * 60 + E % 100; t.start -= t.start % 5; t.end += (5 - t.end % 5) % 5; list.add(t); } Collections.sort(list, new Comparator<T>() { @Override public int compare(T o1, T o2) { return o1.start - o2.start; } }); List<T> ret = new ArrayList<>(); T now = null; for (int i = 0; i < list.size(); i ++) { if (now != null && now.end >= list.get(i).start) { now.end = Math.max(now.end, list.get(i).end); } else { now = list.get(i); ret.add(now); } } for (T t : ret) { String s = String.format("%02d%02d-%02d%02d", t.start / 60, t.start % 60, t.end / 60, t.end % 60); System.out.println(s); } } } class FastScanner { public static String debug = null; private final InputStream in = System.in; private int ptr = 0; private int buflen = 0; private byte[] buffer = new byte[1024]; private boolean eos = false; private boolean hasNextByte() { if (ptr < buflen) { return true; } else { ptr = 0; try { if (debug != null) { buflen = debug.length(); buffer = debug.getBytes(); debug = ""; eos = true; } else { buflen = in.read(buffer); } } catch (IOException e) { e.printStackTrace(); } if (buflen < 0) { eos = true; return false; } else if (buflen == 0) { return false; } } return true; } private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1; } private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126; } private void skipUnprintable() { while (hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; } public boolean isEOS() { return this.eos; } public boolean hasNext() { skipUnprintable(); return hasNextByte(); } public String next() { if (!hasNext()) throw new NoSuchElementException(); StringBuilder sb = new StringBuilder(); int b = readByte(); while (isPrintableChar(b)) { sb.appendCodePoint(b); b = readByte(); } return sb.toString(); } public long nextLong() { if (!hasNext()) throw new NoSuchElementException(); long n = 0; boolean minus = false; int b = readByte(); if (b == '-') { minus = true; b = readByte(); } if (b < '0' || '9' < b) { throw new NumberFormatException(); } while (true) { if ('0' <= b && b <= '9') { n *= 10; n += b - '0'; } else if (b == -1 || !isPrintableChar(b)) { return minus ? -n : n; } else { throw new NumberFormatException(); } b = readByte(); } } public int nextInt() { return (int) nextLong(); } public long[] nextLongList(int n) { return nextLongTable(1, n)[0]; } public int[] nextIntList(int n) { return nextIntTable(1, n)[0]; } public long[][] nextLongTable(int n, int m) { long[][] ret = new long[n][m]; for (int i = 0; i < n; i ++) { for (int j = 0; j < m; j ++) { ret[i][j] = nextLong(); } } return ret; } public int[][] nextIntTable(int n, int m) { int[][] ret = new int[n][m]; for (int i = 0; i < n; i ++) { for (int j = 0; j < m; j ++) { ret[i][j] = nextInt(); } } return ret; } }
Submission Info
Submission Time | |
---|---|
Task | D - 感雨時刻の整理 |
User | hiromi_ayase |
Language | Java (OpenJDK 1.7.0) |
Score | 100 |
Code Size | 3987 Byte |
Status | AC |
Exec Time | 720 ms |
Memory | 35300 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 | 317 ms | 21068 KB |
00_sample_02.txt | AC | 314 ms | 21144 KB |
00_sample_03.txt | AC | 318 ms | 21140 KB |
cho_cho_chokudai.txt | AC | 614 ms | 33872 KB |
chokudai_ga_cho.txt | AC | 651 ms | 34092 KB |
test_01.txt | AC | 376 ms | 22540 KB |
test_02.txt | AC | 376 ms | 22572 KB |
test_03.txt | AC | 375 ms | 22580 KB |
test_04.txt | AC | 365 ms | 22668 KB |
test_05.txt | AC | 364 ms | 22564 KB |
test_06.txt | AC | 318 ms | 21308 KB |
test_07.txt | AC | 316 ms | 21204 KB |
test_08.txt | AC | 312 ms | 21136 KB |
test_09.txt | AC | 338 ms | 22104 KB |
test_10.txt | AC | 339 ms | 22096 KB |
test_11.txt | AC | 338 ms | 22124 KB |
test_12.txt | AC | 327 ms | 22092 KB |
test_13.txt | AC | 319 ms | 21240 KB |
test_14.txt | AC | 333 ms | 22072 KB |
test_15.txt | AC | 340 ms | 22236 KB |
test_16.txt | AC | 316 ms | 21156 KB |
test_17.txt | AC | 335 ms | 22084 KB |
test_18.txt | AC | 317 ms | 21152 KB |
test_19.txt | AC | 329 ms | 22032 KB |
test_20.txt | AC | 328 ms | 22088 KB |
test_21.txt | AC | 664 ms | 34548 KB |
test_22.txt | AC | 677 ms | 35052 KB |
test_23.txt | AC | 662 ms | 35300 KB |
test_24.txt | AC | 672 ms | 34744 KB |
test_25.txt | AC | 675 ms | 34264 KB |
test_26.txt | AC | 670 ms | 34700 KB |
test_27.txt | AC | 611 ms | 33584 KB |
test_28.txt | AC | 690 ms | 34276 KB |
test_29.txt | AC | 307 ms | 21088 KB |
test_30.txt | AC | 324 ms | 21136 KB |
test_31.txt | AC | 485 ms | 28184 KB |
test_32.txt | AC | 339 ms | 21064 KB |
test_33.txt | AC | 718 ms | 35280 KB |
test_34.txt | AC | 323 ms | 20996 KB |
test_35.txt | AC | 324 ms | 21200 KB |
test_36.txt | AC | 692 ms | 34696 KB |
test_37.txt | AC | 720 ms | 34612 KB |
test_38.txt | AC | 664 ms | 33764 KB |
test_39.txt | AC | 667 ms | 34524 KB |
test_40.txt | AC | 680 ms | 34024 KB |
test_41.txt | AC | 599 ms | 33968 KB |
test_42.txt | AC | 685 ms | 34936 KB |
test_43.txt | AC | 608 ms | 34512 KB |