AtCoder Beginner Contest 001

Submission #2484871

Source codeソースコード

import java.util.*;

public class Main {
	public static void main(String... args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[][] a = new int[24][12];

		while (sc.hasNext()) {
			String t = sc.next();
			int s = floor(Integer.parseInt(t.substring(0, 4)));
			int e = ceil(Integer.parseInt(t.substring(5)));

			for (int i = s / 60; i <= e / 60; i++) {
				for (int k = 0; k * 5 + i * 60 < e && k < 12; k++) {
					if (s <= i * 60 + k * 5) {
						a[i][k] = 1;
					}
				}
			}
		}

		boolean onCount = false;
		String s = "";
		String e = "";
		for (int i = 0; i < 24; i++) {
			for (int k = 0; k < 12; k++) {
				if (a[i][k] == 1) {
					if (!onCount) {
						s = calc(i,k);
						onCount = true;
					}
				} else {
					if (onCount) {
						e = calc(i,k);
						System.out.println(s + "-" + e);
						onCount = false;
					}
				}
				if (i == 23 && k == 11 && onCount) {
					System.out.println(s + "-" + "2400");
				}
			}
		}
	}

	private static int floor(int a) {
		return a / 100 * 60 + a % 100 - a % 5;
	}

	private static int ceil(int a) {
		if (a % 5 == 0) {
			return a / 100 * 60 + a % 100;
		} else {
			return a / 100 * 60 + a % 100 + (5 - a % 5);
		}
	}

	private static String calc (int a, int b) {
		String h = "";
		String m = "";
		if (a < 10){
			h = "0" + a;
		} else {
			h = String.valueOf(a);
		}
		if (b <= 1){
			m = "0" + b * 5;
		} else {
			m = String.valueOf(b*5);
		}

		return h + m;
	}
}

Submission

Task問題 D - 感雨時刻の整理
User nameユーザ名 i_whammy
Created time投稿日時
Language言語 Java8 (OpenJDK 1.8.0)
Status状態 AC
Score得点 100
Source lengthソースコード長 1527 Byte
File nameファイル名
Exec time実行時間 322 ms
Memory usageメモリ使用量 43888 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 94 ms 21588 KB
00_sample_02.txt AC 93 ms 18644 KB
00_sample_03.txt AC 96 ms 18644 KB
cho_cho_chokudai.txt AC 286 ms 40900 KB
chokudai_ga_cho.txt AC 301 ms 38136 KB
test_01.txt AC 122 ms 19668 KB
test_02.txt AC 109 ms 23252 KB
test_03.txt AC 109 ms 19924 KB
test_04.txt AC 119 ms 19540 KB
test_05.txt AC 118 ms 21844 KB
test_06.txt AC 115 ms 21076 KB
test_07.txt AC 114 ms 20052 KB
test_08.txt AC 103 ms 21460 KB
test_09.txt AC 126 ms 22356 KB
test_10.txt AC 117 ms 19920 KB
test_11.txt AC 124 ms 21588 KB
test_12.txt AC 123 ms 21076 KB
test_13.txt AC 107 ms 21588 KB
test_14.txt AC 128 ms 20052 KB
test_15.txt AC 129 ms 21972 KB
test_16.txt AC 103 ms 18644 KB
test_17.txt AC 120 ms 19156 KB
test_18.txt AC 117 ms 17748 KB
test_19.txt AC 123 ms 22484 KB
test_20.txt AC 124 ms 22484 KB
test_21.txt AC 268 ms 41116 KB
test_22.txt AC 284 ms 40296 KB
test_23.txt AC 262 ms 43588 KB
test_24.txt AC 266 ms 40424 KB
test_25.txt AC 281 ms 40376 KB
test_26.txt AC 275 ms 43484 KB
test_27.txt AC 269 ms 39788 KB
test_28.txt AC 265 ms 43888 KB
test_29.txt AC 94 ms 23124 KB
test_30.txt AC 100 ms 19156 KB
test_31.txt AC 161 ms 24712 KB
test_32.txt AC 97 ms 20052 KB
test_33.txt AC 226 ms 33904 KB
test_34.txt AC 92 ms 20692 KB
test_35.txt AC 114 ms 19028 KB
test_36.txt AC 285 ms 41276 KB
test_37.txt AC 272 ms 43636 KB
test_38.txt AC 275 ms 39384 KB
test_39.txt AC 264 ms 40352 KB
test_40.txt AC 272 ms 43000 KB
test_41.txt AC 321 ms 42856 KB
test_42.txt AC 305 ms 38704 KB
test_43.txt AC 322 ms 43132 KB