結果

問題 No.521 Cheeses and a Mousetrap(チーズとネズミ捕り)
ユーザー fjafjafja
提出日時 2017-07-18 16:30:09
言語 Java
(openjdk 23)
結果
AC  
実行時間 122 ms / 2,000 ms
コード長 355 bytes
コンパイル時間 3,433 ms
コンパイル使用メモリ 73,984 KB
実行使用メモリ 41,712 KB
最終ジャッジ日時 2024-10-08 10:54:19
合計ジャッジ時間 7,449 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 28
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class N521 {

	public static void main(String[] args)
	{
		Scanner sc=new Scanner(System.in);
		int N=sc.nextInt();
		int K=sc.nextInt();
		int max=0;

		if(K==0||K>N)
		{
			max=0;
		}
		else
		{
			if((N%2)==1&&((K==(N+1)/2)))
			{
				max=N-1;
			}
			else
			{
				max=N-2;
			}
		}
		System.out.println(max);

	}

}
0