結果

問題 No.9 モンスターのレベル上げ
ユーザー letrangerjpletrangerjp
提出日時 2017-05-14 15:54:21
言語 Ruby
(3.1.1p18 )
結果
AC  
実行時間 3,589 ms / 5,000 ms
コード長 450 bytes
コンパイル時間 31 ms
使用メモリ 14,212 KB
最終ジャッジ日時 2023-01-21 16:33:12
合計ジャッジ時間 34,862 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 74 ms
13,832 KB
testcase_01 AC 74 ms
13,808 KB
testcase_02 AC 3,550 ms
14,112 KB
testcase_03 AC 2,699 ms
14,068 KB
testcase_04 AC 1,414 ms
14,100 KB
testcase_05 AC 936 ms
13,964 KB
testcase_06 AC 358 ms
13,956 KB
testcase_07 AC 78 ms
13,752 KB
testcase_08 AC 455 ms
14,032 KB
testcase_09 AC 3,424 ms
14,060 KB
testcase_10 AC 73 ms
13,716 KB
testcase_11 AC 2,817 ms
14,000 KB
testcase_12 AC 3,589 ms
14,072 KB
testcase_13 AC 3,483 ms
14,080 KB
testcase_14 AC 3,427 ms
14,092 KB
testcase_15 AC 3,141 ms
14,212 KB
testcase_16 AC 117 ms
14,076 KB
testcase_17 AC 1,960 ms
14,212 KB
testcase_18 AC 1,622 ms
14,072 KB
testcase_19 AC 100 ms
13,896 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