結果

問題 No.521 Cheeses and a Mousetrap(チーズとネズミ捕り)
ユーザー ryubokuryuboku
提出日時 2017-06-23 23:07:10
言語 Java21
(openjdk 21)
結果
AC  
実行時間 150 ms / 2,000 ms
コード長 444 bytes
コンパイル時間 2,190 ms
コンパイル使用メモリ 74,676 KB
実行使用メモリ 54,520 KB
最終ジャッジ日時 2024-04-14 06:16:18
合計ジャッジ時間 7,830 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 144 ms
53,988 KB
testcase_01 AC 147 ms
54,136 KB
testcase_02 AC 149 ms
54,336 KB
testcase_03 AC 148 ms
54,264 KB
testcase_04 AC 147 ms
54,520 KB
testcase_05 AC 143 ms
54,132 KB
testcase_06 AC 145 ms
54,244 KB
testcase_07 AC 144 ms
54,328 KB
testcase_08 AC 142 ms
54,216 KB
testcase_09 AC 145 ms
54,104 KB
testcase_10 AC 145 ms
54,408 KB
testcase_11 AC 144 ms
54,304 KB
testcase_12 AC 145 ms
54,084 KB
testcase_13 AC 142 ms
53,968 KB
testcase_14 AC 142 ms
54,248 KB
testcase_15 AC 142 ms
54,268 KB
testcase_16 AC 143 ms
54,220 KB
testcase_17 AC 143 ms
54,356 KB
testcase_18 AC 145 ms
54,176 KB
testcase_19 AC 147 ms
54,428 KB
testcase_20 AC 142 ms
54,128 KB
testcase_21 AC 147 ms
54,504 KB
testcase_22 AC 144 ms
53,988 KB
testcase_23 AC 145 ms
54,012 KB
testcase_24 AC 143 ms
54,296 KB
testcase_25 AC 144 ms
54,440 KB
testcase_26 AC 146 ms
54,156 KB
testcase_27 AC 150 ms
54,300 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main{
    public static void main(String args[] ) throws Exception {
        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 + 1) / 2) {
            System.out.println(n - 1);
        } else {
            System.out.println(n - 2);
        }
    }    
}
0