結果

問題 No.521 Cheeses and a Mousetrap(チーズとネズミ捕り)
ユーザー tentententen
提出日時 2021-02-09 08:44:20
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 430 bytes
コンパイル時間 2,218 ms
コンパイル使用メモリ 71,904 KB
実行使用メモリ 58,152 KB
最終ジャッジ日時 2023-09-20 19:15:12
合計ジャッジ時間 7,254 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 122 ms
55,736 KB
testcase_01 WA -
testcase_02 AC 122 ms
55,508 KB
testcase_03 AC 122 ms
56,364 KB
testcase_04 AC 122 ms
53,452 KB
testcase_05 AC 123 ms
55,604 KB
testcase_06 AC 124 ms
56,008 KB
testcase_07 AC 123 ms
55,780 KB
testcase_08 AC 124 ms
55,500 KB
testcase_09 AC 126 ms
55,996 KB
testcase_10 AC 125 ms
55,512 KB
testcase_11 AC 128 ms
55,820 KB
testcase_12 AC 125 ms
55,824 KB
testcase_13 AC 132 ms
55,792 KB
testcase_14 AC 123 ms
55,804 KB
testcase_15 AC 123 ms
55,752 KB
testcase_16 WA -
testcase_17 AC 120 ms
55,756 KB
testcase_18 WA -
testcase_19 AC 123 ms
56,264 KB
testcase_20 WA -
testcase_21 AC 123 ms
55,372 KB
testcase_22 WA -
testcase_23 AC 126 ms
55,840 KB
testcase_24 WA -
testcase_25 AC 122 ms
55,944 KB
testcase_26 WA -
testcase_27 AC 121 ms
55,780 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 (k % 2 == 1 && (k + 1) / 2 == k) {
            ans = n - 1;
        } else {
            ans = n - 2;
        }
        System.out.println(ans);
    }
}
0