結果

問題 No.365 ジェンガソート
ユーザー nihi9119nihi9119
提出日時 2017-06-20 15:48:47
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 2,093 bytes
コンパイル時間 4,226 ms
コンパイル使用メモリ 78,272 KB
実行使用メモリ 61,184 KB
最終ジャッジ日時 2024-04-10 04:24:02
合計ジャッジ時間 9,621 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 49 ms
50,220 KB
testcase_01 AC 50 ms
50,152 KB
testcase_02 AC 50 ms
50,272 KB
testcase_03 AC 48 ms
50,040 KB
testcase_04 AC 49 ms
50,224 KB
testcase_05 AC 49 ms
50,312 KB
testcase_06 AC 50 ms
50,008 KB
testcase_07 AC 49 ms
50,056 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 49 ms
50,324 KB
testcase_15 AC 49 ms
50,216 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 95 ms
52,172 KB
testcase_19 AC 210 ms
60,252 KB
testcase_20 AC 131 ms
54,388 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 AC 162 ms
59,220 KB
testcase_37 AC 210 ms
60,476 KB
testcase_38 WA -
testcase_39 AC 208 ms
60,468 KB
testcase_40 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

package test8;

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

/**
 * No.365 ジェンガソート
 * https://yukicoder.me/problems/no/365
 */

public class Question_24_0921 {

	final static int COUNT_MIN = 1;
	final static int LENTTH_MIN = 1;
	final static int COUNT_MAX = 100000;
	static int LENTTH_MAX;

	public static void main(String[] args) {
		InputStreamReader re = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(re);

		try {
			int count = Integer.parseInt(br.readLine());
			LENTTH_MAX = count;
			String[] inputStr = br.readLine().split(" ");
			int firstNum = Integer.parseInt(inputStr[0]);
			int minNum = 0;
			boolean errorFlg = false;

			//有効値判定
			if (NumJudg(count, COUNT_MIN, COUNT_MAX) && NumJudg(firstNum, LENTTH_MIN, LENTTH_MAX)) {

				if (firstNum != 1) {
					for (int i = 1; i < inputStr.length; i++) {
						int num = Integer.parseInt(inputStr[i]);
						if (NumJudg(num, LENTTH_MIN, LENTTH_MAX)) {
							if (num < firstNum) {
								minNum++;
							}
						} else {
							errorFlg = true;
							break;
						}
					}
				}

				if (errorFlg) {
					System.out.println("入力値が有効範囲外です");
				} else {
					System.out.println(minNum);
				}

			} 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