結果

問題 No.521 Cheeses and a Mousetrap(チーズとネズミ捕り)
ユーザー YamaKasaYamaKasa
提出日時 2018-06-02 19:15:23
言語 Java21
(openjdk 21)
結果
AC  
実行時間 126 ms / 2,000 ms
コード長 394 bytes
コンパイル時間 1,929 ms
コンパイル使用メモリ 71,856 KB
実行使用メモリ 58,116 KB
最終ジャッジ日時 2023-09-12 21:34:39
合計ジャッジ時間 6,789 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 122 ms
56,212 KB
testcase_01 AC 122 ms
55,628 KB
testcase_02 AC 122 ms
55,640 KB
testcase_03 AC 120 ms
55,128 KB
testcase_04 AC 122 ms
57,568 KB
testcase_05 AC 123 ms
56,416 KB
testcase_06 AC 123 ms
55,764 KB
testcase_07 AC 124 ms
58,116 KB
testcase_08 AC 121 ms
55,808 KB
testcase_09 AC 122 ms
55,096 KB
testcase_10 AC 122 ms
55,852 KB
testcase_11 AC 122 ms
55,840 KB
testcase_12 AC 122 ms
56,360 KB
testcase_13 AC 121 ms
55,592 KB
testcase_14 AC 121 ms
55,344 KB
testcase_15 AC 123 ms
55,744 KB
testcase_16 AC 123 ms
55,516 KB
testcase_17 AC 122 ms
55,924 KB
testcase_18 AC 122 ms
55,612 KB
testcase_19 AC 123 ms
56,384 KB
testcase_20 AC 121 ms
55,756 KB
testcase_21 AC 121 ms
56,588 KB
testcase_22 AC 121 ms
55,896 KB
testcase_23 AC 126 ms
56,264 KB
testcase_24 AC 121 ms
55,636 KB
testcase_25 AC 121 ms
55,716 KB
testcase_26 AC 123 ms
56,084 KB
testcase_27 AC 123 ms
56,072 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int K = scan.nextInt();
		scan.close();
		if(K == 0 || K > N) {
			System.out.println(0);
			System.exit(0);
		}
		if(N % 2 == 1 && K == N / 2 + 1) {
			System.out.println(N - 1);
			System.exit(0);
		}
		System.out.println(N - 2);
	}
}
0