AtCoder Beginner Contest 001

Submission #110504

Source codeソースコード

import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
 
 
public class Main {
	private static  InputStream is = null;

	static {
		is = System.in;
	}

	/**
	* @param args
	*/
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		boolean[]	res = new boolean[290];
		int			cnt = parseNum();
		int			min = 288;
		int			max = 0;
		boolean		chk = false;
		char[]		out = new char[9];

		Arrays.fill(out, '-');

		for (int i = 0; i < cnt; i++) {
			Integer[]	rng = parseRange();

			min = (min > rng[0]) ? rng[0] : min;
			max = (max < rng[1]) ? rng[1] : max;

			Arrays.fill(res, rng[0], rng[1], true);
		}

		for (int i = min; i < max+1; i++) {
			if (!chk && res[i]) {
				out[0] = (char)('0'+((i*5)/60)/10);
				out[1] = (char)('0'+((i*5)/60)%10);
				out[2] = (char)('0'+((i*5)%60)/10);
				out[3] = (char)('0'+((i*5)%60)%10);
				chk = true;
			} else if (chk && !res[i]) {
				out[5] = (char)('0'+((i*5)/60)/10);
				out[6] = (char)('0'+((i*5)/60)%10);
				out[7] = (char)('0'+((i*5)%60)/10);
				out[8] = (char)('0'+((i*5)%60)%10);
				chk = false;
				System.out.println(out);
			}
		}
	}

	private static Integer[] parseRange() {
		Integer[]	rng = new Integer[2];

		rng[0] = parseNum();
		rng[0] = (rng[0]/100)*60 + rng[0]%100;
		rng[0] = rng[0]/5;

		rng[1] = parseNum();
		rng[1] = (rng[1]/100)*60 + rng[1]%100;
		rng[1] = rng[1]/5+(((rng[1]%5)>0)?1:0);

		return rng;
	}

	private static int parseNum() {
		try {
			int	buf = 0;
			int	num = 0;

			// 0~9以外は読み飛ばす
			while ((buf = is.read()) != -1 && !((buf >= '0' && buf <= '9')));
			num = buf-'0';
			while (true) {
				buf = is.read();
				if (buf >= '0' && buf <= '9') {
					num = num * 10 + (buf - '0');
				} else {
					return num;
				}
			}
		} catch (IOException e) {}
		return -1;
	}
}

Submission

Task問題 D - 感雨時刻の整理
User nameユーザ名 あらまき
Created time投稿日時
Language言語 Java (OpenJDK 1.7.0)
Status状態 AC
Score得点 100
Source lengthソースコード長 1915 Byte
File nameファイル名
Exec time実行時間 491 ms
Memory usageメモリ使用量 28532 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 380 ms 20584 KB
00_sample_02.txt AC 374 ms 20564 KB
00_sample_03.txt AC 377 ms 20580 KB
cho_cho_chokudai.txt AC 454 ms 27356 KB
chokudai_ga_cho.txt AC 457 ms 27644 KB
test_01.txt AC 376 ms 20580 KB
test_02.txt AC 380 ms 20576 KB
test_03.txt AC 382 ms 20572 KB
test_04.txt AC 376 ms 20576 KB
test_05.txt AC 376 ms 20572 KB
test_06.txt AC 390 ms 20956 KB
test_07.txt AC 389 ms 20948 KB
test_08.txt AC 377 ms 20964 KB
test_09.txt AC 387 ms 21212 KB
test_10.txt AC 402 ms 21092 KB
test_11.txt AC 390 ms 21008 KB
test_12.txt AC 407 ms 20892 KB
test_13.txt AC 375 ms 20580 KB
test_14.txt AC 402 ms 21208 KB
test_15.txt AC 398 ms 21084 KB
test_16.txt AC 379 ms 20572 KB
test_17.txt AC 418 ms 21008 KB
test_18.txt AC 389 ms 20568 KB
test_19.txt AC 408 ms 20956 KB
test_20.txt AC 382 ms 20564 KB
test_21.txt AC 468 ms 27808 KB
test_22.txt AC 469 ms 28448 KB
test_23.txt AC 482 ms 28184 KB
test_24.txt AC 469 ms 28532 KB
test_25.txt AC 473 ms 27316 KB
test_26.txt AC 462 ms 28028 KB
test_27.txt AC 472 ms 27552 KB
test_28.txt AC 476 ms 28152 KB
test_29.txt AC 378 ms 20576 KB
test_30.txt AC 381 ms 20508 KB
test_31.txt AC 415 ms 21972 KB
test_32.txt AC 387 ms 20568 KB
test_33.txt AC 460 ms 26428 KB
test_34.txt AC 387 ms 20452 KB
test_35.txt AC 389 ms 20448 KB
test_36.txt AC 491 ms 28036 KB
test_37.txt AC 484 ms 27776 KB
test_38.txt AC 473 ms 27760 KB
test_39.txt AC 477 ms 25240 KB
test_40.txt AC 474 ms 27740 KB
test_41.txt AC 465 ms 28068 KB
test_42.txt AC 463 ms 27468 KB
test_43.txt AC 468 ms 28112 KB