Submission #4296905


Source Code Expand

import java.io.InputStream;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	private int indexOf(Integer[] a, Integer e, int idx) {
		if (idx == -1)
			return -1;
		for (int i = idx; i < a.length; i++) {
			if (a[i].equals(e)) {
				return i;
			}
		}
		return -1;
	}

	private List<List<String>> seiri(List<List<String>> l) {
		Integer[] m = new Integer[2400 / 5];
		Arrays.fill(m, 0);

		for (List<String> ll : l) {
			int lhs = Integer.parseInt(ll.get(0));
			int rhs = Integer.parseInt(ll.get(1));

			int lhsIdx = lhs / 5;
			int rhsIdx = rhs / 5;

			Arrays.fill(m, lhsIdx, rhsIdx, 1);

		}

		List<List<String>> r = new ArrayList<>();

		int i = 0;
		while (true) {
			int lidx = indexOf(m, 1, i);
			int ridx = indexOf(m, 0, lidx);

			String ls, rs;

			if (lidx == -1) {
				break;
			}

			ls = String.format("%04d", lidx * 5);

			if (ridx == -1) {
				rs = "2400";
				i = 2400 / 5;
			} else {
				rs = String.format("%04d", ridx * 5);
				i = ridx + 1;
			}

			r.add(Arrays.asList(ls, rs));

		}

		return r;
	}

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		int n = sc.nextInt();

		List<List<String>> l = new ArrayList<>();

		for (int i = 0; i < n; i++) {
			String s = sc.next().trim();

			int lhs = Integer.parseInt(s.substring(0, 4));
			int rhs = Integer.parseInt(s.substring(5, 9));

			lhs -= lhs % 5;
			rhs += (5 - (rhs % 5)) % 5;

			l.add(new ArrayList<String>(Arrays.asList(String.format("%04d", lhs), String.format("%04d", rhs))));
		}

		List<List<String>> result = seiri(l);

		for (List<String> rr : result) {
			out.println(rr.get(0) + "-" + rr.get(1));
		}

		sc.close();
	}

	public static void main(String[] args) {
		new Main()._main(args);
	}

}

Submission Info

Submission Time
Task D - 感雨時刻の整理
User puvon
Language Java8 (OpenJDK 1.8.0)
Score 0
Code Size 1976 Byte
Status WA
Exec Time 827 ms
Memory 76008 KB

Judge Result

Set Name all
Score / Max Score 0 / 100
Status
AC × 27
WA × 3
MLE × 18
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 93 ms 19156 KB
00_sample_02.txt AC 93 ms 21844 KB
00_sample_03.txt AC 96 ms 23124 KB
cho_cho_chokudai.txt MLE 788 ms 66012 KB
chokudai_ga_cho.txt MLE 827 ms 63040 KB
test_01.txt AC 144 ms 23192 KB
test_02.txt AC 148 ms 22684 KB
test_03.txt AC 142 ms 23252 KB
test_04.txt AC 143 ms 22740 KB
test_05.txt AC 142 ms 22556 KB
test_06.txt AC 139 ms 21584 KB
test_07.txt AC 120 ms 20940 KB
test_08.txt AC 114 ms 21844 KB
test_09.txt AC 173 ms 23124 KB
test_10.txt AC 165 ms 25428 KB
test_11.txt AC 170 ms 22992 KB
test_12.txt AC 163 ms 25172 KB
test_13.txt AC 124 ms 20176 KB
test_14.txt AC 181 ms 25180 KB
test_15.txt AC 189 ms 27092 KB
test_16.txt AC 135 ms 20308 KB
test_17.txt AC 154 ms 24404 KB
test_18.txt AC 132 ms 21972 KB
test_19.txt AC 146 ms 22996 KB
test_20.txt AC 156 ms 25300 KB
test_21.txt MLE 721 ms 54604 KB
test_22.txt MLE 704 ms 66164 KB
test_23.txt AC 725 ms 51400 KB
test_24.txt MLE 749 ms 63316 KB
test_25.txt MLE 742 ms 65308 KB
test_26.txt MLE 785 ms 75756 KB
test_27.txt MLE 786 ms 76008 KB
test_28.txt MLE 732 ms 64904 KB
test_29.txt AC 93 ms 19156 KB
test_30.txt WA 107 ms 19540 KB
test_31.txt WA 296 ms 37636 KB
test_32.txt AC 113 ms 18768 KB
test_33.txt MLE 560 ms 54428 KB
test_34.txt AC 94 ms 21844 KB
test_35.txt WA 135 ms 22484 KB
test_36.txt MLE 727 ms 65364 KB
test_37.txt MLE 731 ms 66660 KB
test_38.txt MLE 706 ms 64604 KB
test_39.txt MLE 761 ms 64880 KB
test_40.txt MLE 695 ms 71428 KB
test_41.txt MLE 763 ms 64816 KB
test_42.txt MLE 767 ms 65812 KB
test_43.txt MLE 717 ms 66996 KB