Submission #171118


Source Code Expand

import java.util.Iterator;
import java.util.Map.Entry;
import java.util.Scanner;
import java.util.TreeMap;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int num = sc.nextInt();
		TreeMap<Integer, Integer> map = new TreeMap<Integer, Integer>();
		//
		for (int i=0; i<num; i++) {
			String[] str = sc.next().split("-");
			int beginTime = ((int)(Integer.valueOf(str[0])/5))*5;
			int endTime = (int)Math.ceil(Integer.valueOf(str[1])/5.0)*5;
			if (String.valueOf(endTime).endsWith("60")) endTime+=40;
			if (map.containsKey(beginTime)) {
				if (map.get(beginTime)<endTime) {
					map.put(beginTime, endTime);
				}
			} else {
				map.put(beginTime, endTime);
			}
		}
		//
		Iterator<Entry<Integer, Integer>> it = map.entrySet().iterator();
		TreeMap<Integer, Integer> map2 = new TreeMap<Integer, Integer>();
		Entry<Integer, Integer> firstEntry = it.next();
		map2.put(firstEntry.getKey(), firstEntry.getValue());
		while (it.hasNext()) {
			Entry<Integer, Integer> e = it.next();
			Entry<Integer, Integer> lastEntry = map2.lastEntry();
			if (lastEntry.getValue()>=e.getKey()) {
				map2.put(lastEntry.getKey(), Math.max(lastEntry.getValue(), e.getValue()));
			} else {
				map2.put(e.getKey(), e.getValue());
			}
		}
		//
		for (it=map2.entrySet().iterator(); it.hasNext();) {
			Entry<Integer, Integer> e = it.next();
			System.out.println(String.format("%04d-%04d", e.getKey(), e.getValue()));
		}
		sc.close();
	}
}

Submission Info

Submission Time
Task D - 感雨時刻の整理
User keitoff314
Language Java (OpenJDK 1.7.0)
Score 100
Code Size 1528 Byte
Status AC
Exec Time 1022 ms
Memory 39272 KB

Judge Result

Set Name all
Score / Max Score 100 / 100
Status
AC × 48
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 463 ms 20756 KB
00_sample_02.txt AC 421 ms 20680 KB
00_sample_03.txt AC 434 ms 20680 KB
cho_cho_chokudai.txt AC 928 ms 37720 KB
chokudai_ga_cho.txt AC 957 ms 38864 KB
test_01.txt AC 463 ms 21196 KB
test_02.txt AC 468 ms 21192 KB
test_03.txt AC 471 ms 21196 KB
test_04.txt AC 477 ms 21200 KB
test_05.txt AC 471 ms 21176 KB
test_06.txt AC 470 ms 21576 KB
test_07.txt AC 431 ms 21064 KB
test_08.txt AC 427 ms 20816 KB
test_09.txt AC 481 ms 22028 KB
test_10.txt AC 490 ms 22008 KB
test_11.txt AC 481 ms 21956 KB
test_12.txt AC 472 ms 21700 KB
test_13.txt AC 449 ms 21068 KB
test_14.txt AC 490 ms 22088 KB
test_15.txt AC 532 ms 22096 KB
test_16.txt AC 430 ms 20932 KB
test_17.txt AC 480 ms 21956 KB
test_18.txt AC 461 ms 20940 KB
test_19.txt AC 472 ms 21700 KB
test_20.txt AC 487 ms 21936 KB
test_21.txt AC 913 ms 36884 KB
test_22.txt AC 959 ms 38092 KB
test_23.txt AC 994 ms 39272 KB
test_24.txt AC 918 ms 37268 KB
test_25.txt AC 916 ms 37084 KB
test_26.txt AC 955 ms 38468 KB
test_27.txt AC 912 ms 37456 KB
test_28.txt AC 1022 ms 37960 KB
test_29.txt AC 570 ms 20700 KB
test_30.txt AC 425 ms 20808 KB
test_31.txt AC 674 ms 27124 KB
test_32.txt AC 435 ms 20808 KB
test_33.txt AC 897 ms 35312 KB
test_34.txt AC 411 ms 20672 KB
test_35.txt AC 476 ms 21192 KB
test_36.txt AC 931 ms 38572 KB
test_37.txt AC 958 ms 38300 KB
test_38.txt AC 903 ms 36808 KB
test_39.txt AC 940 ms 38344 KB
test_40.txt AC 932 ms 36876 KB
test_41.txt AC 926 ms 38704 KB
test_42.txt AC 942 ms 37192 KB
test_43.txt AC 927 ms 36360 KB