結果

問題 No.521 Cheeses and a Mousetrap(チーズとネズミ捕り)
ユーザー tsunabittsunabit
提出日時 2019-06-13 01:48:21
言語 Java21
(openjdk 21)
結果
AC  
実行時間 137 ms / 2,000 ms
コード長 429 bytes
コンパイル時間 3,340 ms
コンパイル使用メモリ 74,652 KB
実行使用メモリ 54,228 KB
最終ジャッジ日時 2024-04-20 10:59:58
合計ジャッジ時間 7,984 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 130 ms
54,172 KB
testcase_01 AC 113 ms
53,044 KB
testcase_02 AC 130 ms
54,124 KB
testcase_03 AC 115 ms
52,900 KB
testcase_04 AC 127 ms
54,168 KB
testcase_05 AC 127 ms
53,932 KB
testcase_06 AC 114 ms
53,132 KB
testcase_07 AC 128 ms
53,976 KB
testcase_08 AC 126 ms
53,916 KB
testcase_09 AC 130 ms
54,048 KB
testcase_10 AC 132 ms
54,060 KB
testcase_11 AC 132 ms
54,084 KB
testcase_12 AC 130 ms
54,216 KB
testcase_13 AC 129 ms
54,104 KB
testcase_14 AC 126 ms
53,848 KB
testcase_15 AC 129 ms
54,108 KB
testcase_16 AC 133 ms
54,224 KB
testcase_17 AC 131 ms
54,208 KB
testcase_18 AC 129 ms
54,080 KB
testcase_19 AC 130 ms
54,052 KB
testcase_20 AC 129 ms
54,140 KB
testcase_21 AC 129 ms
54,140 KB
testcase_22 AC 128 ms
54,108 KB
testcase_23 AC 129 ms
53,992 KB
testcase_24 AC 117 ms
53,052 KB
testcase_25 AC 137 ms
54,228 KB
testcase_26 AC 131 ms
54,120 KB
testcase_27 AC 130 ms
54,028 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
import java.io.*;
import java.math.*;

public class No521 {
    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	int n = sc.nextInt(), k = sc.nextInt();
    	
    	if(k == 0 || k > n) {
    		System.out.println(0);
    		return;
    	}
    	if(n % 2 != 0 && (n / 2 + 1 == k)) {
    		System.out.println(n -1);
    	}else {
    		System.out.println(n -2);
    	}
    }
}
0