結果

問題 No.1052 電子機器X
ユーザー ks2mks2m
提出日時 2020-05-15 21:50:00
言語 Java21
(openjdk 21)
結果
AC  
実行時間 142 ms / 1,000 ms
コード長 434 bytes
コンパイル時間 4,018 ms
コンパイル使用メモリ 74,024 KB
実行使用メモリ 57,720 KB
最終ジャッジ日時 2023-10-19 13:20:07
合計ジャッジ時間 6,495 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 135 ms
57,660 KB
testcase_01 AC 132 ms
57,524 KB
testcase_02 AC 136 ms
57,496 KB
testcase_03 AC 142 ms
57,720 KB
testcase_04 AC 140 ms
57,428 KB
testcase_05 AC 133 ms
57,496 KB
testcase_06 AC 132 ms
57,484 KB
testcase_07 AC 132 ms
57,636 KB
testcase_08 AC 133 ms
55,468 KB
testcase_09 AC 130 ms
57,452 KB
testcase_10 AC 130 ms
57,500 KB
testcase_11 AC 132 ms
57,592 KB
testcase_12 AC 133 ms
57,480 KB
testcase_13 AC 132 ms
57,448 KB
testcase_14 AC 132 ms
57,516 KB
testcase_15 AC 134 ms
57,492 KB
testcase_16 AC 131 ms
57,492 KB
testcase_17 AC 119 ms
56,284 KB
testcase_18 AC 130 ms
57,392 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		sc.close();

		if (n % 2 == 0) {
			int ans = n / 2;
			int k1 = 1 + k;
			int k2 = n + 1 - k;
			if (k1 < k2) {
				ans -= (k2 - k1) / 2 - 1;
			}
			System.out.println(ans);
		} else {
			System.out.println(Math.min(n, k + 1));
		}
	}
}
0