結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 121 ms
56,028 KB
testcase_01 AC 120 ms
55,664 KB
testcase_02 AC 121 ms
56,348 KB
testcase_03 AC 120 ms
55,780 KB
testcase_04 AC 122 ms
56,140 KB
testcase_05 AC 120 ms
54,176 KB
testcase_06 AC 122 ms
56,160 KB
testcase_07 AC 120 ms
55,712 KB
testcase_08 AC 121 ms
55,860 KB
testcase_09 AC 121 ms
55,840 KB
testcase_10 AC 122 ms
55,928 KB
testcase_11 AC 122 ms
56,056 KB
testcase_12 AC 120 ms
55,812 KB
testcase_13 AC 120 ms
55,632 KB
testcase_14 AC 122 ms
56,184 KB
testcase_15 AC 122 ms
55,752 KB
testcase_16 AC 121 ms
55,912 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 121 ms
56,388 KB
testcase_20 WA -
testcase_21 AC 121 ms
56,032 KB
testcase_22 WA -
testcase_23 AC 121 ms
55,320 KB
testcase_24 WA -
testcase_25 AC 122 ms
56,300 KB
testcase_26 WA -
testcase_27 AC 121 ms
56,104 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 && (n + 1) / 2 == k) {
            ans = n - 1;
        } else {
            ans = n - 2;
        }
        System.out.println(ans);
    }
}
0