Submission #296308
Source Code Expand
import java.io.*; import java.util.*; public class Main { FastScanner in = new FastScanner(System.in); PrintWriter out = new PrintWriter(System.out); class Pair implements Comparable<Pair> { int from, to; Pair(int from, int to) { this.from = from; this.to = to; } public int compareTo(Pair s) { return from - s.from; } } String extend(int x) { String res = Integer.toString(x); while (res.length() < 4) res = "0" + res; return res; } public void run() { int n = in.nextInt(); Pair[] times = new Pair[n]; for (int i = 0; i < n; i++) { String[] next = in.next().split("-"); int from = Integer.valueOf(next[0]); int to = Integer.valueOf(next[1]); from -= (from % 5); to += (5 - (to % 5)) % 5; times[i] = new Pair(from, to); // System.out.println(from + " " + to); } Arrays.sort(times); for (int i = 0; i < n; i++) { int from = times[i].from, to = times[i].to; for (int j = i + 1; j < n; j++) { if (times[j].from <= to) { to = Math.max(times[j].to, to); } else { i = j - 1; break; } } System.out.println(extend(from) + "-" + extend(to)); } out.close(); } public static void main(String[] args) { new Main().run(); } public void mapDebug(int[][] a) { System.out.println("--------map display---------"); for (int i = 0; i < a.length; i++) { for (int j = 0; j < a[i].length; j++) { System.out.printf("%3d ", a[i][j]); } System.out.println(); } System.out.println("----------------------------"); System.out.println(); } public void debug(Object... obj) { System.out.println(Arrays.deepToString(obj)); } class FastScanner { private InputStream stream; private byte[] buf = new byte[1024]; private int curChar; private int numChars; public FastScanner(InputStream stream) { this.stream = stream; //stream = new FileInputStream(new File("dec.in")); } int read() { if (numChars == -1) throw new InputMismatchException(); if (curChar >= numChars) { curChar = 0; try { numChars = stream.read(buf); } catch (IOException e) { throw new InputMismatchException(); } if (numChars <= 0) return -1; } return buf[curChar++]; } boolean isSpaceChar(int c) { return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1; } boolean isEndline(int c) { return c == '\n' || c == '\r' || c == -1; } int nextInt() { return Integer.parseInt(next()); } int[] nextIntArray(int n) { int[] array = new int[n]; for (int i = 0; i < n; i++) array[i] = nextInt(); return array; } int[][] nextIntMap(int n, int m) { int[][] map = new int[n][m]; for (int i = 0; i < n; i++) { map[i] = in.nextIntArray(m); } return map; } long nextLong() { return Long.parseLong(next()); } long[] nextLongArray(int n) { long[] array = new long[n]; for (int i = 0; i < n; i++) array[i] = nextLong(); return array; } long[][] nextLongMap(int n, int m) { long[][] map = new long[n][m]; for (int i = 0; i < n; i++) { map[i] = in.nextLongArray(m); } return map; } double nextDouble() { return Double.parseDouble(next()); } double[] nextDoubleArray(int n) { double[] array = new double[n]; for (int i = 0; i < n; i++) array[i] = nextDouble(); return array; } double[][] nextDoubleMap(int n, int m) { double[][] map = new double[n][m]; for (int i = 0; i < n; i++) { map[i] = in.nextDoubleArray(m); } return map; } String next() { int c = read(); while (isSpaceChar(c)) c = read(); StringBuilder res = new StringBuilder(); do { res.appendCodePoint(c); c = read(); } while (!isSpaceChar(c)); return res.toString(); } String[] nextStringArray(int n) { String[] array = new String[n]; for (int i = 0; i < n; i++) array[i] = next(); return array; } String nextLine() { int c = read(); while (isEndline(c)) c = read(); StringBuilder res = new StringBuilder(); do { res.appendCodePoint(c); c = read(); } while (!isEndline(c)); return res.toString(); } } }
Submission Info
Submission Time | |
---|---|
Task | D - 感雨時刻の整理 |
User | hiro116s |
Language | Java (OpenJDK 1.7.0) |
Score | 0 |
Code Size | 4394 Byte |
Status | TLE |
Exec Time | 2058 ms |
Memory | 36624 KB |
Judge Result
Set Name | all | ||||||
---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 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 | 397 ms | 20896 KB |
00_sample_02.txt | AC | 393 ms | 20904 KB |
00_sample_03.txt | AC | 391 ms | 20880 KB |
cho_cho_chokudai.txt | TLE | 2048 ms | 34880 KB |
chokudai_ga_cho.txt | TLE | 2050 ms | 36108 KB |
test_01.txt | AC | 404 ms | 21012 KB |
test_02.txt | AC | 412 ms | 21028 KB |
test_03.txt | AC | 402 ms | 20944 KB |
test_04.txt | AC | 400 ms | 21096 KB |
test_05.txt | AC | 403 ms | 20884 KB |
test_06.txt | WA | 436 ms | 22820 KB |
test_07.txt | WA | 419 ms | 21692 KB |
test_08.txt | WA | 402 ms | 21020 KB |
test_09.txt | WA | 463 ms | 23044 KB |
test_10.txt | WA | 472 ms | 23124 KB |
test_11.txt | WA | 436 ms | 22020 KB |
test_12.txt | WA | 440 ms | 22900 KB |
test_13.txt | WA | 430 ms | 22516 KB |
test_14.txt | WA | 455 ms | 23076 KB |
test_15.txt | WA | 467 ms | 23224 KB |
test_16.txt | WA | 423 ms | 21928 KB |
test_17.txt | WA | 460 ms | 23108 KB |
test_18.txt | WA | 439 ms | 23240 KB |
test_19.txt | WA | 459 ms | 22920 KB |
test_20.txt | WA | 456 ms | 23064 KB |
test_21.txt | TLE | 2046 ms | 36104 KB |
test_22.txt | TLE | 2049 ms | 36436 KB |
test_23.txt | TLE | 2047 ms | 36624 KB |
test_24.txt | TLE | 2044 ms | 35240 KB |
test_25.txt | TLE | 2043 ms | 35776 KB |
test_26.txt | WA | 846 ms | 36000 KB |
test_27.txt | TLE | 2053 ms | 35500 KB |
test_28.txt | WA | 816 ms | 36352 KB |
test_29.txt | AC | 400 ms | 20968 KB |
test_30.txt | WA | 399 ms | 21028 KB |
test_31.txt | WA | 547 ms | 27464 KB |
test_32.txt | WA | 397 ms | 21028 KB |
test_33.txt | WA | 819 ms | 35068 KB |
test_34.txt | AC | 393 ms | 20940 KB |
test_35.txt | WA | 429 ms | 21160 KB |
test_36.txt | TLE | 2050 ms | 36348 KB |
test_37.txt | WA | 846 ms | 35564 KB |
test_38.txt | WA | 797 ms | 35512 KB |
test_39.txt | WA | 955 ms | 36100 KB |
test_40.txt | WA | 913 ms | 34960 KB |
test_41.txt | TLE | 2043 ms | 35256 KB |
test_42.txt | TLE | 2045 ms | 36396 KB |
test_43.txt | TLE | 2058 ms | 35336 KB |