Submission #296310


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 {
					break;
				}
				i = j;
			}
			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 4389 Byte
Status WA
Exec Time 744 ms
Memory 33172 KB

Judge Result

Set Name all
Score / Max Score 0 / 100
Status
AC × 38
WA × 10
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 365 ms 17716 KB
00_sample_02.txt AC 358 ms 17908 KB
00_sample_03.txt AC 360 ms 17920 KB
cho_cho_chokudai.txt WA 609 ms 31184 KB
chokudai_ga_cho.txt AC 605 ms 30980 KB
test_01.txt AC 373 ms 18020 KB
test_02.txt AC 375 ms 17984 KB
test_03.txt AC 377 ms 17848 KB
test_04.txt AC 372 ms 17952 KB
test_05.txt AC 374 ms 17980 KB
test_06.txt AC 369 ms 17896 KB
test_07.txt AC 365 ms 17828 KB
test_08.txt AC 369 ms 17924 KB
test_09.txt AC 382 ms 19028 KB
test_10.txt AC 387 ms 19084 KB
test_11.txt AC 385 ms 18776 KB
test_12.txt AC 389 ms 18592 KB
test_13.txt AC 367 ms 17940 KB
test_14.txt AC 379 ms 18816 KB
test_15.txt AC 390 ms 18904 KB
test_16.txt AC 381 ms 17868 KB
test_17.txt AC 378 ms 18784 KB
test_18.txt AC 369 ms 17872 KB
test_19.txt AC 392 ms 18504 KB
test_20.txt AC 408 ms 18724 KB
test_21.txt AC 675 ms 32116 KB
test_22.txt AC 744 ms 33172 KB
test_23.txt AC 674 ms 32808 KB
test_24.txt AC 679 ms 31904 KB
test_25.txt AC 740 ms 32952 KB
test_26.txt WA 733 ms 32952 KB
test_27.txt AC 638 ms 31572 KB
test_28.txt WA 689 ms 32372 KB
test_29.txt AC 359 ms 17848 KB
test_30.txt WA 373 ms 17804 KB
test_31.txt WA 515 ms 22528 KB
test_32.txt AC 357 ms 17816 KB
test_33.txt WA 730 ms 31588 KB
test_34.txt AC 374 ms 17920 KB
test_35.txt WA 378 ms 17988 KB
test_36.txt AC 716 ms 31576 KB
test_37.txt WA 736 ms 32948 KB
test_38.txt WA 667 ms 32040 KB
test_39.txt AC 682 ms 32648 KB
test_40.txt WA 699 ms 32460 KB
test_41.txt AC 600 ms 31176 KB
test_42.txt AC 675 ms 32216 KB
test_43.txt AC 631 ms 31364 KB