結果

問題 No.521 Cheeses and a Mousetrap(チーズとネズミ捕り)
ユーザー mosmos_21mosmos_21
提出日時 2017-06-20 11:43:22
言語 Java21
(openjdk 21)
結果
AC  
実行時間 135 ms / 2,000 ms
コード長 418 bytes
コンパイル時間 2,578 ms
コンパイル使用メモリ 74,392 KB
実行使用メモリ 54,536 KB
最終ジャッジ日時 2024-04-10 02:18:05
合計ジャッジ時間 7,211 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 135 ms
54,000 KB
testcase_01 AC 122 ms
54,040 KB
testcase_02 AC 124 ms
54,004 KB
testcase_03 AC 117 ms
53,776 KB
testcase_04 AC 120 ms
54,536 KB
testcase_05 AC 109 ms
53,056 KB
testcase_06 AC 110 ms
52,996 KB
testcase_07 AC 121 ms
54,012 KB
testcase_08 AC 123 ms
54,156 KB
testcase_09 AC 123 ms
54,116 KB
testcase_10 AC 126 ms
53,860 KB
testcase_11 AC 124 ms
54,104 KB
testcase_12 AC 123 ms
54,108 KB
testcase_13 AC 126 ms
54,328 KB
testcase_14 AC 125 ms
54,000 KB
testcase_15 AC 124 ms
53,936 KB
testcase_16 AC 124 ms
53,968 KB
testcase_17 AC 124 ms
53,944 KB
testcase_18 AC 123 ms
54,012 KB
testcase_19 AC 122 ms
54,296 KB
testcase_20 AC 128 ms
54,044 KB
testcase_21 AC 120 ms
53,956 KB
testcase_22 AC 126 ms
54,008 KB
testcase_23 AC 120 ms
53,996 KB
testcase_24 AC 122 ms
54,232 KB
testcase_25 AC 122 ms
54,000 KB
testcase_26 AC 121 ms
53,904 KB
testcase_27 AC 108 ms
52,960 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {
    static Scanner in = new Scanner(System.in);

    public static void main(String[] args) {
        int N = in.nextInt(), K = in.nextInt();
        if (K < 1 || N < K) {
            System.out.println(0);
        } else if (K == N / 2 + 1 && N % 2 == 1) {
            System.out.println(N - 1);
        } else {
            System.out.println(N - 2);
        }
    }
}
0