結果

問題 No.521 Cheeses and a Mousetrap(チーズとネズミ捕り)
ユーザー tentententen
提出日時 2021-02-09 08:46:12
言語 Java21
(openjdk 21)
結果
AC  
実行時間 133 ms / 2,000 ms
コード長 430 bytes
コンパイル時間 4,051 ms
コンパイル使用メモリ 71,156 KB
実行使用メモリ 55,836 KB
最終ジャッジ日時 2023-09-20 19:16:45
合計ジャッジ時間 8,932 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 132 ms
55,628 KB
testcase_01 AC 131 ms
55,620 KB
testcase_02 AC 131 ms
55,620 KB
testcase_03 AC 130 ms
55,756 KB
testcase_04 AC 128 ms
55,332 KB
testcase_05 AC 133 ms
55,548 KB
testcase_06 AC 128 ms
55,460 KB
testcase_07 AC 132 ms
55,272 KB
testcase_08 AC 130 ms
55,628 KB
testcase_09 AC 130 ms
55,512 KB
testcase_10 AC 131 ms
55,668 KB
testcase_11 AC 132 ms
55,820 KB
testcase_12 AC 128 ms
55,600 KB
testcase_13 AC 128 ms
55,636 KB
testcase_14 AC 131 ms
55,696 KB
testcase_15 AC 129 ms
55,748 KB
testcase_16 AC 130 ms
55,764 KB
testcase_17 AC 129 ms
55,312 KB
testcase_18 AC 130 ms
55,596 KB
testcase_19 AC 131 ms
55,504 KB
testcase_20 AC 130 ms
55,628 KB
testcase_21 AC 130 ms
53,440 KB
testcase_22 AC 132 ms
55,664 KB
testcase_23 AC 130 ms
55,512 KB
testcase_24 AC 133 ms
55,836 KB
testcase_25 AC 131 ms
55,444 KB
testcase_26 AC 130 ms
55,612 KB
testcase_27 AC 130 ms
55,484 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int ans;
        if (k == 0 || k > n) {
            ans = 0;
        } else if (n % 2 == 1 && (n + 1) / 2 == k) {
            ans = n - 1;
        } else {
            ans = n - 2;
        }
        System.out.println(ans);
    }
}
0