結果

問題 No.521 Cheeses and a Mousetrap(チーズとネズミ捕り)
ユーザー YamaKasa
提出日時 2018-06-02 19:15:23
言語 Java
(openjdk 23)
結果
AC  
実行時間 137 ms / 2,000 ms
コード長 394 bytes
コンパイル時間 1,956 ms
コンパイル使用メモリ 73,832 KB
実行使用メモリ 41,788 KB
最終ジャッジ日時 2024-06-30 09:04:33
合計ジャッジ時間 6,849 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 28
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int K = scan.nextInt();
		scan.close();
		if(K == 0 || K > N) {
			System.out.println(0);
			System.exit(0);
		}
		if(N % 2 == 1 && K == N / 2 + 1) {
			System.out.println(N - 1);
			System.exit(0);
		}
		System.out.println(N - 2);
	}
}
0