結果

問題 No.296 n度寝
ユーザー nihi9119nihi9119
提出日時 2017-06-08 17:46:08
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 2,257 bytes
コンパイル時間 4,355 ms
コンパイル使用メモリ 78,060 KB
実行使用メモリ 54,816 KB
最終ジャッジ日時 2023-10-23 19:51:20
合計ジャッジ時間 5,977 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 AC 52 ms
53,608 KB
testcase_04 AC 52 ms
53,608 KB
testcase_05 AC 52 ms
53,616 KB
testcase_06 AC 51 ms
53,608 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 52 ms
53,616 KB
testcase_11 AC 53 ms
53,616 KB
testcase_12 WA -
testcase_13 AC 52 ms
53,612 KB
testcase_14 AC 52 ms
53,620 KB
testcase_15 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

package test_5;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;

public class Question_14_0608 {

	static final int SLEEP_MIN = 1;
	static final int HUER_MIN = 0;
	static final int MINUTE_MIN = 0;
	static final int INTERVAL_MIN = 1;
	static final int SLEEP_MAX = (int)Math.pow(10, 9);
	static final int HUER_MAX = 23;
	static final int MINUTE_MAX = 59;
	static final int INTERVAL_MAX = 1440; // 24*60

	public static void main(String[] args) {

		InputStreamReader re = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(re);
		ArrayList<Integer> resultList = new ArrayList<Integer>();

		try {
			String[] input = br.readLine().split(" ");
			int sleepNum = Integer.parseInt(input[0]);
			int huer = Integer.parseInt(input[1]);
			int minute = Integer.parseInt(input[2]);
			int interval = Integer.parseInt(input[3]);

			//有効値チェック
			if (NumJudg(sleepNum, SLEEP_MIN, SLEEP_MAX)
					&& NumJudg(huer, HUER_MIN, HUER_MAX)
					&& NumJudg(minute, MINUTE_MIN, MINUTE_MAX)
					&& NumJudg(interval, INTERVAL_MIN, INTERVAL_MAX)) {

				//最終起床時間 分単位
				int sumMin = 0;
				//起床するまでの合計(分)
				for (int i = 0; i < sleepNum - 1; i++) {
					sumMin += interval;
				}
				sumMin += huer * 60 + minute;

				//起床時間
				System.out.println(sumMin / 60);
				System.out.println(sumMin % 60);

			} else {
				System.out.println("有効値範囲外です");
			}

		} catch (NumberFormatException e) {
			System.out.println("数字を入力して下さい。");
		} catch (IOException e) {
			System.out.println("エラーが発生しました。");
		} finally {
			try {
				re.close();
				br.close();
			} catch (IOException e) {
				System.out.println("InputStreamReader、BufferedReaderクローズ中にエラーが発生しました");
			}
		}
	}

	/**
	 * 有効値判定
	 * @param input 判定するもの
	 * @param max 最大値
	 * @param min 最小値
	 * @return 範囲内ならtrue,範囲外ならfalseを返す
	 */
	private static boolean NumJudg(int input, int min, int max) {
		Boolean result = false;
		if (min <= input && input <= max) {
			result = true;
		}
		return result;
	}
}
0