AtCoder Beginner Contest 001

Submission #240723

Source codeソースコード


import java.util.*;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		TreeMap<Integer,Integer> rain = new TreeMap<>();
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		for(int i=0;i<N;i++){
			String aa  = sc.next();
			int a = Integer.parseInt(aa.substring(0, 4));
			int b =Integer.parseInt(aa.substring(5, 9));
			a-=(a%100)%5;
			if((b%100)>55){
				b=(b/100+1)*100;
			}else if(b%100%5==0){ b=b;
			}else{
				b+=5-(b%100)%5;
			}
			if(rain.containsKey(a)){
				if(rain.get(a)<b){
					 rain.put(a, b);
				}
			}
			else rain.put(a, b);
		}
		Set<Integer> s = rain.keySet();	
		int start=111110;
		int end =-111111;
		boolean flag = false;
		for(int p:s){
			if(p>end&&flag){				
				System.out.println(String.format("%04d", start)+"-"+String.format("%04d", end));
				start =p;
				end=rain.get(p);
			}
			if(p<start){
				start=p;
				end=rain.get(p);
				flag = true;
			}
			if(p<=end){
				end = Math.max(end, rain.get(p));
			}
		}
		System.out.println(String.format("%04d", start)+"-"+String.format("%04d", end));

	}
}

Submission

Task問題 D - 感雨時刻の整理
User nameユーザ名 024_kou
Created time投稿日時
Language言語 Java (OpenJDK 1.7.0)
Status状態 AC
Score得点 100
Source lengthソースコード長 1175 Byte
File nameファイル名
Exec time実行時間 843 ms
Memory usageメモリ使用量 40428 KB

Test case

Set

Set name Score得点 / Max score Cases
all 100 / 100 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

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
00_sample_01.txt AC 464 ms 23840 KB
00_sample_02.txt AC 494 ms 23840 KB
00_sample_03.txt AC 466 ms 23948 KB
cho_cho_chokudai.txt AC 843 ms 38944 KB
chokudai_ga_cho.txt AC 830 ms 40428 KB
test_01.txt AC 530 ms 24328 KB
test_02.txt AC 521 ms 24380 KB
test_03.txt AC 548 ms 24448 KB
test_04.txt AC 524 ms 24452 KB
test_05.txt AC 512 ms 24392 KB
test_06.txt AC 498 ms 24724 KB
test_07.txt AC 491 ms 24040 KB
test_08.txt AC 499 ms 23904 KB
test_09.txt AC 521 ms 25276 KB
test_10.txt AC 529 ms 25264 KB
test_11.txt AC 515 ms 24700 KB
test_12.txt AC 518 ms 24812 KB
test_13.txt AC 486 ms 24212 KB
test_14.txt AC 538 ms 25424 KB
test_15.txt AC 523 ms 25908 KB
test_16.txt AC 495 ms 24168 KB
test_17.txt AC 523 ms 25316 KB
test_18.txt AC 475 ms 24204 KB
test_19.txt AC 501 ms 24356 KB
test_20.txt AC 517 ms 24956 KB
test_21.txt AC 810 ms 39684 KB
test_22.txt AC 810 ms 39368 KB
test_23.txt AC 810 ms 39364 KB
test_24.txt AC 806 ms 39780 KB
test_25.txt AC 806 ms 40092 KB
test_26.txt AC 774 ms 36584 KB
test_27.txt AC 780 ms 38544 KB
test_28.txt AC 797 ms 39000 KB
test_29.txt AC 469 ms 23932 KB
test_30.txt AC 466 ms 24032 KB
test_31.txt AC 614 ms 29096 KB
test_32.txt AC 465 ms 23972 KB
test_33.txt AC 746 ms 36196 KB
test_34.txt AC 470 ms 23924 KB
test_35.txt AC 481 ms 24836 KB
test_36.txt AC 821 ms 40208 KB
test_37.txt AC 820 ms 39948 KB
test_38.txt AC 832 ms 39128 KB
test_39.txt AC 827 ms 39952 KB
test_40.txt AC 789 ms 38772 KB
test_41.txt AC 787 ms 38652 KB
test_42.txt AC 792 ms 39492 KB
test_43.txt AC 780 ms 38504 KB