結果

問題 No.521 Cheeses and a Mousetrap(チーズとネズミ捕り)
ユーザー fkwnw3_1243fkwnw3_1243
提出日時 2017-09-08 22:44:04
言語 Java21
(openjdk 21)
結果
AC  
実行時間 53 ms / 2,000 ms
コード長 756 bytes
コンパイル時間 3,594 ms
コンパイル使用メモリ 73,636 KB
実行使用メモリ 37,132 KB
最終ジャッジ日時 2024-04-24 20:39:15
合計ジャッジ時間 6,061 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 51 ms
36,892 KB
testcase_01 AC 52 ms
36,928 KB
testcase_02 AC 51 ms
36,836 KB
testcase_03 AC 50 ms
37,100 KB
testcase_04 AC 50 ms
36,592 KB
testcase_05 AC 49 ms
36,680 KB
testcase_06 AC 51 ms
36,912 KB
testcase_07 AC 51 ms
36,880 KB
testcase_08 AC 50 ms
36,920 KB
testcase_09 AC 51 ms
36,984 KB
testcase_10 AC 52 ms
36,804 KB
testcase_11 AC 52 ms
36,912 KB
testcase_12 AC 52 ms
37,132 KB
testcase_13 AC 53 ms
36,860 KB
testcase_14 AC 47 ms
37,092 KB
testcase_15 AC 51 ms
36,616 KB
testcase_16 AC 51 ms
36,888 KB
testcase_17 AC 53 ms
36,896 KB
testcase_18 AC 51 ms
36,680 KB
testcase_19 AC 53 ms
36,828 KB
testcase_20 AC 51 ms
36,932 KB
testcase_21 AC 50 ms
37,128 KB
testcase_22 AC 51 ms
36,548 KB
testcase_23 AC 51 ms
36,836 KB
testcase_24 AC 51 ms
37,012 KB
testcase_25 AC 50 ms
36,868 KB
testcase_26 AC 52 ms
36,820 KB
testcase_27 AC 52 ms
36,516 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

import static java.lang.System.in;

public class No521 {
    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(in));
        String[] inputs = reader.readLine().split(" ");
        long N = Long.parseLong(inputs[0]);
        long K = Long.parseLong(inputs[1]);

        if (K == 0 || K > N) {
            System.out.println(0);
        } else {
            long left = K;
            long right = N - K + 1;
            if (left == right) {
                System.out.println(N - 1);
            } else {
                System.out.println(N - 2);
            }
        }
    }
}
0