結果

問題 No.1052 電子機器X
ユーザー ks2m
提出日時 2020-05-15 21:44:29
言語 Java
(openjdk 23)
結果
WA  
実行時間 -
コード長 486 bytes
コンパイル時間 2,565 ms
コンパイル使用メモリ 74,312 KB
実行使用メモリ 41,628 KB
最終ジャッジ日時 2024-09-19 09:07:42
合計ジャッジ時間 5,075 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 15 WA * 1
権限があれば一括ダウンロードができます

ソースコード

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 {
			int k2 = k + 1;
			if (k % 2 == 0) {
				k2++;
			}
			System.out.println(Math.min(n, k2));
		}
	}
}
0