結果

問題 No.521 Cheeses and a Mousetrap(チーズとネズミ捕り)
ユーザー fukuseifukusei
提出日時 2018-03-08 17:30:31
言語 Java21
(openjdk 21)
結果
AC  
実行時間 158 ms / 2,000 ms
コード長 539 bytes
コンパイル時間 2,241 ms
コンパイル使用メモリ 74,456 KB
実行使用メモリ 54,776 KB
最終ジャッジ日時 2024-04-15 12:15:50
合計ジャッジ時間 7,537 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 150 ms
54,288 KB
testcase_01 AC 147 ms
54,196 KB
testcase_02 AC 147 ms
54,172 KB
testcase_03 AC 148 ms
54,280 KB
testcase_04 AC 149 ms
54,228 KB
testcase_05 AC 148 ms
54,352 KB
testcase_06 AC 148 ms
53,936 KB
testcase_07 AC 146 ms
53,848 KB
testcase_08 AC 154 ms
53,956 KB
testcase_09 AC 151 ms
54,216 KB
testcase_10 AC 155 ms
54,280 KB
testcase_11 AC 148 ms
54,180 KB
testcase_12 AC 145 ms
53,936 KB
testcase_13 AC 151 ms
54,252 KB
testcase_14 AC 148 ms
54,376 KB
testcase_15 AC 150 ms
54,776 KB
testcase_16 AC 147 ms
54,424 KB
testcase_17 AC 154 ms
54,188 KB
testcase_18 AC 147 ms
54,016 KB
testcase_19 AC 149 ms
54,156 KB
testcase_20 AC 148 ms
54,024 KB
testcase_21 AC 153 ms
53,860 KB
testcase_22 AC 150 ms
53,992 KB
testcase_23 AC 151 ms
54,400 KB
testcase_24 AC 158 ms
54,252 KB
testcase_25 AC 148 ms
54,108 KB
testcase_26 AC 150 ms
54,428 KB
testcase_27 AC 150 ms
53,956 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();
        
        if(K<=0 || K>N){
            System.out.println(0);
        }
        else if(N%2 == 0){
            System.out.println(N-2);
        }
        else{
            if( ( (N+1)/2) == K ){
                System.out.println(N-1);
            }
            else{
                System.out.println(N-2);
            }
        }
    }
}
0