結果

問題 No.1052 電子機器X
ユーザー simansiman
提出日時 2020-11-11 06:21:15
言語 Ruby
(3.3.0)
結果
AC  
実行時間 71 ms / 1,000 ms
コード長 212 bytes
コンパイル時間 483 ms
コンパイル使用メモリ 11,124 KB
実行使用メモリ 15,324 KB
最終ジャッジ日時 2023-09-30 00:20:47
合計ジャッジ時間 2,600 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 66 ms
15,268 KB
testcase_01 AC 71 ms
15,292 KB
testcase_02 AC 70 ms
15,056 KB
testcase_03 AC 68 ms
15,296 KB
testcase_04 AC 66 ms
15,324 KB
testcase_05 AC 70 ms
15,248 KB
testcase_06 AC 65 ms
15,060 KB
testcase_07 AC 68 ms
15,132 KB
testcase_08 AC 66 ms
15,296 KB
testcase_09 AC 66 ms
15,284 KB
testcase_10 AC 66 ms
15,096 KB
testcase_11 AC 65 ms
15,056 KB
testcase_12 AC 67 ms
15,244 KB
testcase_13 AC 70 ms
15,064 KB
testcase_14 AC 70 ms
15,012 KB
testcase_15 AC 65 ms
15,132 KB
testcase_16 AC 65 ms
15,296 KB
testcase_17 AC 65 ms
15,140 KB
testcase_18 AC 67 ms
15,136 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

N, K = gets.split.map(&:to_i)

if N.even?
  if 1 + K < N - (K - 1)
    puts [N / 2, K + 1].min
  else
    puts N / 2
  end
else
  a = [N / 2, (K + 1) / 2].min
  b = [(N + 1) / 2, K / 2 + 1].min

  puts a + b
end
0