結果

問題 No.521 Cheeses and a Mousetrap(チーズとネズミ捕り)
ユーザー samplelpmassamplelpmas
提出日時 2017-06-05 11:26:25
言語 Java21
(openjdk 21)
結果
AC  
実行時間 133 ms / 2,000 ms
コード長 459 bytes
コンパイル時間 2,019 ms
コンパイル使用メモリ 75,004 KB
実行使用メモリ 57,560 KB
最終ジャッジ日時 2023-10-22 05:30:44
合計ジャッジ時間 6,807 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 132 ms
57,492 KB
testcase_01 AC 130 ms
57,412 KB
testcase_02 AC 131 ms
57,368 KB
testcase_03 AC 130 ms
57,344 KB
testcase_04 AC 129 ms
57,192 KB
testcase_05 AC 129 ms
57,488 KB
testcase_06 AC 130 ms
57,332 KB
testcase_07 AC 129 ms
57,280 KB
testcase_08 AC 130 ms
57,560 KB
testcase_09 AC 127 ms
55,548 KB
testcase_10 AC 129 ms
57,484 KB
testcase_11 AC 130 ms
57,296 KB
testcase_12 AC 130 ms
57,464 KB
testcase_13 AC 131 ms
57,396 KB
testcase_14 AC 132 ms
57,424 KB
testcase_15 AC 119 ms
56,136 KB
testcase_16 AC 127 ms
57,204 KB
testcase_17 AC 127 ms
57,264 KB
testcase_18 AC 129 ms
57,292 KB
testcase_19 AC 130 ms
57,492 KB
testcase_20 AC 133 ms
57,488 KB
testcase_21 AC 131 ms
57,468 KB
testcase_22 AC 130 ms
57,384 KB
testcase_23 AC 133 ms
57,344 KB
testcase_24 AC 132 ms
57,388 KB
testcase_25 AC 132 ms
57,432 KB
testcase_26 AC 131 ms
57,436 KB
testcase_27 AC 131 ms
57,460 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int K = sc.nextInt();

        if (K == 0 || K > N) {
            System.out.println(0);
            return;
        }

        if (N % 2 == 1 && K == (N + 1) / 2) {
            System.out.println(N - 1);
        } else {
            System.out.println(N - 2);
        }

    }

}
0