Submission #335369


Source Code Expand

import java.lang.reflect.Array;
import java.util.*;

public class Main {
	public static void main(String[] args)
	{
		int n;
		Integer [] start, end;
		String[] data;
		Scanner sc = new Scanner(System.in);

		n = sc.nextInt();
		start = new Integer[n];
		end = new Integer[n];
		data = new String[n];
		
		for(int i = 0; i < n; i++) data[i] = sc.next();
		sc.close();
		//時間順(昇順)ソート
		Arrays.sort(data);
		
		//降り始めと振り終わりに分ける
		separate(start,end, n, data);
		
		//雨が振った時間がかぶっている場合合成
		connect(start, end, n);
		
		//重複なしで出力
		normalization(start, end, n);

	}

	private static void separate(Integer[] start, Integer[] end, int n, String[] data)
	{
		int i, tmp;
		for(i = 0; i < n; i++){
			String[] change = (data[i]).split("-");
			marume(start,end,change, i);
			//System.out.println(start[i]);
			//System.out.println(end[i]);
		}
	}
	
	private static void marume(Integer[] start, Integer[] end, String[] change, int i)
	{
		int tmp;
		//start
		tmp = Integer.parseInt(change[0]);
		start[i] = (tmp - (tmp % 5));
	
		//end
		tmp = Integer.parseInt(change[1]) + 4;
		end[i] = tmp - (tmp % 5);
		if(end[i] % 100 == 60) end[i] = end[i] - 60 + 100;
	}

	private static void connect(Integer[] start, Integer[] end, int n)
	{
		int i,k;
		for(i = 0; i < n; i++){
			for(k = i + 1; k < n; k++){
				if(start[k] <= end[i]){
					if(end[k] <= end[i]){
						end[k] = end[i];
					} else {
						end[i] = end[k];
					}
				}

			}
		}
	}

	private static void normalization(Integer[] start, Integer[] end, int n)
	{
		int i;
		System.out.println(String.format("%04d-%04d", start[0], end[0]));
		for(i = 1; i < n; i++){
			//System.out.println(start[i] + "-" + end[i]);
			if(end[i - 1] < start[i]){
				System.out.println(String.format("%04d-%04d", start[i], end[i]));
			}
		}
	}

}

Submission Info

Submission Time
Task D - 感雨時刻の整理
User ne260037
Language Java (OpenJDK 1.7.0)
Score 0
Code Size 1960 Byte
Status TLE
Exec Time 2048 ms
Memory 43760 KB

Judge Result

Set Name all
Score / Max Score 0 / 100
Status
AC × 29
TLE × 19
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 360 ms 22708 KB
00_sample_02.txt AC 351 ms 22940 KB
00_sample_03.txt AC 353 ms 22856 KB
cho_cho_chokudai.txt TLE 2044 ms 42644 KB
chokudai_ga_cho.txt TLE 2045 ms 43760 KB
test_01.txt AC 420 ms 23248 KB
test_02.txt AC 409 ms 23396 KB
test_03.txt AC 408 ms 23288 KB
test_04.txt AC 407 ms 23376 KB
test_05.txt AC 403 ms 23264 KB
test_06.txt AC 391 ms 23820 KB
test_07.txt AC 371 ms 23068 KB
test_08.txt AC 369 ms 22988 KB
test_09.txt AC 431 ms 25040 KB
test_10.txt AC 438 ms 25044 KB
test_11.txt AC 421 ms 24004 KB
test_12.txt AC 404 ms 23432 KB
test_13.txt AC 378 ms 23220 KB
test_14.txt AC 424 ms 25036 KB
test_15.txt AC 436 ms 25120 KB
test_16.txt AC 378 ms 23288 KB
test_17.txt AC 434 ms 25160 KB
test_18.txt AC 389 ms 23248 KB
test_19.txt AC 409 ms 23468 KB
test_20.txt AC 418 ms 23844 KB
test_21.txt TLE 2044 ms 42756 KB
test_22.txt TLE 2048 ms 41564 KB
test_23.txt TLE 2044 ms 43304 KB
test_24.txt TLE 2046 ms 42316 KB
test_25.txt TLE 2044 ms 42572 KB
test_26.txt TLE 2044 ms 42372 KB
test_27.txt TLE 2044 ms 40500 KB
test_28.txt TLE 2044 ms 41872 KB
test_29.txt AC 349 ms 22860 KB
test_30.txt AC 356 ms 22980 KB
test_31.txt AC 676 ms 30120 KB
test_32.txt AC 359 ms 22836 KB
test_33.txt TLE 2044 ms 40276 KB
test_34.txt AC 349 ms 22988 KB
test_35.txt AC 384 ms 23616 KB
test_36.txt TLE 2044 ms 42580 KB
test_37.txt TLE 2045 ms 42772 KB
test_38.txt TLE 2045 ms 42200 KB
test_39.txt TLE 2045 ms 42832 KB
test_40.txt TLE 2045 ms 42276 KB
test_41.txt TLE 2045 ms 43052 KB
test_42.txt TLE 2045 ms 42236 KB
test_43.txt TLE 2044 ms 43652 KB