AtCoder Beginner Contest 001

Submission #121617

Source codeソースコード

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		boolean[] rainData = new boolean[24 * 12];
		
		int N = sc.nextInt();
		for(int i = 0; i < N; i++) {
			String[] time = sc.next().split("-");
			
			int startHour  = Integer.parseInt(time[0].substring(0, 2));
			int startMinute = Integer.parseInt(time[0].substring(2, 4));
			int endHour    = Integer.parseInt(time[1].substring(0, 2));
			int endMinute   = Integer.parseInt(time[1].substring(2, 4));
			
			for (int j = startHour*12 + startMinute/5; j < endHour*12 + Math.ceil(endMinute/5.0); j++) {
				rainData[j] = true;
			}
		}
		
		String line = null;
		int length = rainData.length;
		for (int i = 0; i < length; i++) {
			if (rainData[i]) {
				if (line == null) {
					String startHour   = String.format("%02d", i / 12);
					String startMinute = String.format("%02d", i % 12  * 5);
					line = startHour + startMinute + "-";
				}
			} else {
				if (line != null) {
					int endHour   = i / 12;
					int endMinute = i % 12  * 5;
					if (endMinute == 60) {
					    endHour++;
					    endMinute = 0;
					}
					String endHourStr = String.format("%02d", endHour);
					String endMinuteStr = String.format("%02d", endMinute);
					System.out.println(line + endHourStr + endMinuteStr);
					line = null;
				}
			}
		}
		if (line != null) {
		    int endHour   = length / 12;
		    int endMinute = length % 12  * 5;
		    if (endMinute == 60) {
		        endHour++;
		        endMinute = 0;
		    }
		    String endHourStr = String.format("%02d", endHour);
			String endMinuteStr = String.format("%02d", endMinute);
			System.out.println(line + endHourStr + endMinuteStr);
		}
	}
	
}

Submission

Task問題 D - 感雨時刻の整理
User nameユーザ名 shibu_t
Created time投稿日時
Language言語 Java (OpenJDK 1.7.0)
Status状態 AC
Score得点 100
Source lengthソースコード長 1787 Byte
File nameファイル名
Exec time実行時間 934 ms
Memory usageメモリ使用量 38072 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 379 ms 21800 KB
00_sample_02.txt AC 381 ms 21844 KB
00_sample_03.txt AC 388 ms 21932 KB
cho_cho_chokudai.txt AC 810 ms 35968 KB
chokudai_ga_cho.txt AC 775 ms 36348 KB
test_01.txt AC 442 ms 22832 KB
test_02.txt AC 443 ms 22836 KB
test_03.txt AC 448 ms 22748 KB
test_04.txt AC 441 ms 22832 KB
test_05.txt AC 441 ms 22820 KB
test_06.txt AC 445 ms 24680 KB
test_07.txt AC 428 ms 23416 KB
test_08.txt AC 419 ms 23116 KB
test_09.txt AC 480 ms 25292 KB
test_10.txt AC 473 ms 25684 KB
test_11.txt AC 455 ms 24612 KB
test_12.txt AC 448 ms 24816 KB
test_13.txt AC 404 ms 22192 KB
test_14.txt AC 474 ms 24872 KB
test_15.txt AC 490 ms 25704 KB
test_16.txt AC 406 ms 22180 KB
test_17.txt AC 468 ms 25456 KB
test_18.txt AC 407 ms 22180 KB
test_19.txt AC 455 ms 24172 KB
test_20.txt AC 432 ms 23208 KB
test_21.txt AC 753 ms 35488 KB
test_22.txt AC 764 ms 35336 KB
test_23.txt AC 772 ms 36180 KB
test_24.txt AC 767 ms 35212 KB
test_25.txt AC 785 ms 35044 KB
test_26.txt AC 808 ms 37212 KB
test_27.txt AC 863 ms 37628 KB
test_28.txt AC 817 ms 36936 KB
test_29.txt AC 380 ms 21968 KB
test_30.txt AC 392 ms 21928 KB
test_31.txt AC 588 ms 28912 KB
test_32.txt AC 390 ms 21928 KB
test_33.txt AC 742 ms 35640 KB
test_34.txt AC 403 ms 21928 KB
test_35.txt AC 412 ms 22448 KB
test_36.txt AC 790 ms 36872 KB
test_37.txt AC 819 ms 36592 KB
test_38.txt AC 811 ms 38072 KB
test_39.txt AC 789 ms 37264 KB
test_40.txt AC 934 ms 37480 KB
test_41.txt AC 790 ms 34988 KB
test_42.txt AC 770 ms 35456 KB
test_43.txt AC 761 ms 34880 KB