結果

問題 No.521 Cheeses and a Mousetrap(チーズとネズミ捕り)
ユーザー GrenacheGrenache
提出日時 2017-06-02 22:24:37
言語 Java19
(openjdk 21)
結果
AC  
実行時間 139 ms / 2,000 ms
コード長 686 bytes
コンパイル時間 3,991 ms
コンパイル使用メモリ 74,680 KB
実行使用メモリ 57,696 KB
最終ジャッジ日時 2023-10-21 20:57:37
合計ジャッジ時間 8,800 ms
ジャッジサーバーID
(参考情報)
judge10 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 137 ms
57,388 KB
testcase_01 AC 139 ms
57,464 KB
testcase_02 AC 136 ms
57,500 KB
testcase_03 AC 139 ms
57,312 KB
testcase_04 AC 138 ms
57,492 KB
testcase_05 AC 138 ms
55,908 KB
testcase_06 AC 138 ms
57,372 KB
testcase_07 AC 136 ms
55,428 KB
testcase_08 AC 139 ms
57,372 KB
testcase_09 AC 139 ms
57,396 KB
testcase_10 AC 139 ms
57,404 KB
testcase_11 AC 137 ms
57,508 KB
testcase_12 AC 137 ms
57,368 KB
testcase_13 AC 136 ms
57,248 KB
testcase_14 AC 137 ms
57,364 KB
testcase_15 AC 138 ms
57,396 KB
testcase_16 AC 137 ms
57,504 KB
testcase_17 AC 139 ms
57,476 KB
testcase_18 AC 136 ms
57,688 KB
testcase_19 AC 136 ms
57,364 KB
testcase_20 AC 136 ms
57,428 KB
testcase_21 AC 135 ms
57,420 KB
testcase_22 AC 137 ms
57,468 KB
testcase_23 AC 135 ms
57,372 KB
testcase_24 AC 135 ms
57,368 KB
testcase_25 AC 137 ms
57,216 KB
testcase_26 AC 137 ms
57,696 KB
testcase_27 AC 135 ms
57,368 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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


public class Main_yukicoder521 {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		int n = sc.nextInt();
		int k = sc.nextInt();

		if (k == 0 || k > n) {
			pr.println(0);
		} else if (n % 2 == 1 && n / 2 + 1 == k) {
			pr.println(n - 1);
		} else {
			pr.println(Math.max(0, n - 2));
		}
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		pr = new Printer(System.out);

		solve();

		pr.close();
		sc.close();
	}

	private static class Printer extends PrintWriter {
		Printer(PrintStream out) {
			super(out);
		}
	}
}
0