AtCoder Beginner Contest 001

Submission #447406

Source codeソースコード

import java.util.Scanner;
import java.util.ArrayList;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int num = scan.nextInt();
		int b1, b2, c1, c2;
		ArrayList<Integer> time = new ArrayList<Integer>();

		// 偶数:降り始め、奇数:降り終わり
		for (int i = 0; i < num; i++) {
			String str = scan.next();
			String[] a = str.split("-", 0);
			// 偶数:秒数表示
			b1 = Integer.parseInt(a[0]);
			b2 = b1 / 100;
			b1 = (b1 - (b2 * 100)) + (b2 * 60);
			b1 -= b1 % 5;
			// 奇数:秒数表示
			c1 = Integer.parseInt(a[1]);
			c2 = c1 / 100;
			c1 = (c1 - (c2 * 100)) + (c2 * 60);
			if (c1 % 5 != 0)
				c1 += 5 - (c1 % 5);

			time.add(b1);
			time.add(c1);
		}

		//フラグ立て
		int flug[] = new int[1441];
		for (int i1 = 0; i1 < num; i1++) {
			for (int i2 = time.get(i1 * 2); i2 <= time.get((i1 * 2) + 1); i2++)
				flug[i2] = 1;
		}
		
		//結果表示
		int result = 0;
		boolean front = true;
		for(int i = 0; i <= 1440; i++){
			if(front && flug[i] == 1){
				front = false;
				result = (i / 60 * 100) + (i % 60);
				System.out.print(String.format("%1$04d", result) + "-");
			}
			
			if(!front && flug[i] == 0){
				front = true;
				result = ((i - 1) / 60 * 100) + ((i - 1) % 60);
				System.out.println(String.format("%1$04d", result));
			}else if(!front && i == 1440){
				result = (i / 60 * 100) + (i % 60);
				System.out.println(String.format("%1$04d", result));
			}
		}
	}
}

Submission

Task問題 D - 感雨時刻の整理
User nameユーザ名 JASON
Created time投稿日時
Language言語 Java (OpenJDK 1.7.0)
Status状態 AC
Score得点 100
Source lengthソースコード長 1544 Byte
File nameファイル名
Exec time実行時間 1158 ms
Memory usageメモリ使用量 34336 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 397 ms 17060 KB
00_sample_02.txt AC 383 ms 17192 KB
00_sample_03.txt AC 380 ms 17040 KB
cho_cho_chokudai.txt AC 1158 ms 33324 KB
chokudai_ga_cho.txt AC 940 ms 34336 KB
test_01.txt AC 444 ms 17640 KB
test_02.txt AC 445 ms 17600 KB
test_03.txt AC 447 ms 17728 KB
test_04.txt AC 454 ms 17636 KB
test_05.txt AC 454 ms 17592 KB
test_06.txt AC 443 ms 18244 KB
test_07.txt AC 425 ms 17824 KB
test_08.txt AC 434 ms 17884 KB
test_09.txt AC 486 ms 20008 KB
test_10.txt AC 493 ms 20200 KB
test_11.txt AC 456 ms 18512 KB
test_12.txt AC 447 ms 18292 KB
test_13.txt AC 435 ms 17888 KB
test_14.txt AC 482 ms 19888 KB
test_15.txt AC 485 ms 20816 KB
test_16.txt AC 424 ms 17784 KB
test_17.txt AC 489 ms 21712 KB
test_18.txt AC 426 ms 17756 KB
test_19.txt AC 444 ms 18172 KB
test_20.txt AC 451 ms 18468 KB
test_21.txt AC 931 ms 33544 KB
test_22.txt AC 892 ms 33320 KB
test_23.txt AC 899 ms 32736 KB
test_24.txt AC 941 ms 33420 KB
test_25.txt AC 949 ms 33936 KB
test_26.txt AC 927 ms 33920 KB
test_27.txt AC 936 ms 34128 KB
test_28.txt AC 931 ms 33928 KB
test_29.txt AC 387 ms 17040 KB
test_30.txt AC 394 ms 17044 KB
test_31.txt AC 620 ms 23596 KB
test_32.txt AC 400 ms 17012 KB
test_33.txt AC 926 ms 32452 KB
test_34.txt AC 396 ms 17012 KB
test_35.txt AC 421 ms 17780 KB
test_36.txt AC 934 ms 33408 KB
test_37.txt AC 945 ms 34248 KB
test_38.txt AC 902 ms 32924 KB
test_39.txt AC 921 ms 33436 KB
test_40.txt AC 910 ms 32700 KB
test_41.txt AC 961 ms 33400 KB
test_42.txt AC 956 ms 33380 KB
test_43.txt AC 1004 ms 33888 KB