結果

問題 No.521 Cheeses and a Mousetrap(チーズとネズミ捕り)
ユーザー Daigo HIROOKADaigo HIROOKA
提出日時 2018-05-16 02:13:26
言語 Java21
(openjdk 21)
結果
AC  
実行時間 129 ms / 2,000 ms
コード長 418 bytes
コンパイル時間 5,737 ms
コンパイル使用メモリ 72,400 KB
実行使用メモリ 56,372 KB
最終ジャッジ日時 2023-09-10 21:10:15
合計ジャッジ時間 8,488 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 123 ms
55,708 KB
testcase_01 AC 126 ms
55,728 KB
testcase_02 AC 127 ms
55,532 KB
testcase_03 AC 125 ms
53,768 KB
testcase_04 AC 125 ms
55,676 KB
testcase_05 AC 129 ms
56,088 KB
testcase_06 AC 123 ms
56,072 KB
testcase_07 AC 124 ms
55,776 KB
testcase_08 AC 124 ms
55,920 KB
testcase_09 AC 123 ms
55,664 KB
testcase_10 AC 124 ms
55,988 KB
testcase_11 AC 124 ms
56,208 KB
testcase_12 AC 124 ms
55,908 KB
testcase_13 AC 123 ms
55,960 KB
testcase_14 AC 124 ms
56,136 KB
testcase_15 AC 123 ms
56,372 KB
testcase_16 AC 124 ms
55,948 KB
testcase_17 AC 124 ms
56,080 KB
testcase_18 AC 124 ms
56,080 KB
testcase_19 AC 124 ms
55,364 KB
testcase_20 AC 123 ms
55,720 KB
testcase_21 AC 124 ms
55,732 KB
testcase_22 AC 123 ms
56,216 KB
testcase_23 AC 124 ms
55,784 KB
testcase_24 AC 123 ms
56,096 KB
testcase_25 AC 123 ms
56,084 KB
testcase_26 AC 122 ms
56,116 KB
testcase_27 AC 124 ms
56,052 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class CheeseAndMouse{
    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);
        }else if(N%2 == 1 && K == N/2+1){
            System.out.println(N-1);
        }else{
            System.out.println(N-2);
        }
    }
}
0