結果

問題 No.9 モンスターのレベル上げ
ユーザー letrangerjpletrangerjp
提出日時 2017-05-14 15:54:21
言語 Ruby
(3.3.0)
結果
AC  
実行時間 3,448 ms / 5,000 ms
コード長 450 bytes
コンパイル時間 77 ms
コンパイル使用メモリ 11,504 KB
実行使用メモリ 16,008 KB
最終ジャッジ日時 2023-09-06 05:19:40
合計ジャッジ時間 34,044 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 80 ms
15,132 KB
testcase_01 AC 80 ms
15,124 KB
testcase_02 AC 3,448 ms
15,612 KB
testcase_03 AC 2,651 ms
15,596 KB
testcase_04 AC 1,387 ms
15,404 KB
testcase_05 AC 922 ms
15,460 KB
testcase_06 AC 351 ms
15,344 KB
testcase_07 AC 85 ms
15,256 KB
testcase_08 AC 455 ms
15,488 KB
testcase_09 AC 3,329 ms
15,584 KB
testcase_10 AC 80 ms
15,232 KB
testcase_11 AC 2,751 ms
16,008 KB
testcase_12 AC 3,438 ms
15,496 KB
testcase_13 AC 3,362 ms
15,636 KB
testcase_14 AC 3,343 ms
15,436 KB
testcase_15 AC 3,052 ms
15,428 KB
testcase_16 AC 125 ms
15,392 KB
testcase_17 AC 2,016 ms
15,488 KB
testcase_18 AC 1,576 ms
15,692 KB
testcase_19 AC 106 ms
15,464 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

def f(a, b)
  _party = a.map{|v| v * MOD}.sort
  troop = b.map{|v|v/2}
  troop.size.times.map{
    party = _party.dup
    troop.each{|elv|
      lv_cnt = party.shift + elv * MOD + 1
      nth = party.bsearch_index{|v| v >= lv_cnt} || party.size
      party.insert(nth, lv_cnt)
    }
    troop.rotate!
    party.map{|v| v % MOD}.max
  }.min
end

N = gets.to_i
A = gets.split.take(N).map(&:to_i)
B = gets.split.take(N).map(&:to_i)
MOD = 2000
p f(A, B)
0