結果

問題 No.9 モンスターのレベル上げ
ユーザー letrangerjpletrangerjp
提出日時 2017-05-15 19:11:13
言語 Ruby
(3.2.2)
結果
AC  
実行時間 3,359 ms / 5,000 ms
コード長 528 bytes
コンパイル時間 445 ms
コンパイル使用メモリ 11,432 KB
実行使用メモリ 16,108 KB
最終ジャッジ日時 2023-09-06 05:18:52
合計ジャッジ時間 17,050 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 83 ms
15,072 KB
testcase_01 AC 79 ms
15,288 KB
testcase_02 AC 1,635 ms
15,796 KB
testcase_03 AC 756 ms
16,108 KB
testcase_04 AC 683 ms
15,628 KB
testcase_05 AC 500 ms
15,496 KB
testcase_06 AC 206 ms
15,696 KB
testcase_07 AC 85 ms
15,180 KB
testcase_08 AC 221 ms
15,796 KB
testcase_09 AC 1,451 ms
15,612 KB
testcase_10 AC 81 ms
15,120 KB
testcase_11 AC 1,642 ms
15,420 KB
testcase_12 AC 3,359 ms
15,464 KB
testcase_13 AC 87 ms
15,296 KB
testcase_14 AC 1,436 ms
15,924 KB
testcase_15 AC 1,497 ms
15,848 KB
testcase_16 AC 98 ms
15,528 KB
testcase_17 AC 989 ms
15,760 KB
testcase_18 AC 803 ms
15,580 KB
testcase_19 AC 96 ms
15,656 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

def f(a, b)
  _party = a.sort.map{|v| v * MOD}
  troop = b.map{|v| v / 2 * MOD}
  troop.size.times.inject(1.0/0){|r|
    party = _party.dup
    (troop.all?{|elv|
      lv_cnt = party.shift + elv + 1
      if lv_cnt % MOD < r
        nth = party.bsearch_index{|v| v >= lv_cnt} || party.size
        party.insert(nth, lv_cnt)
      end
    } ? [r, party.map{|v| v % MOD}.max].min : r).tap{
      troop.rotate!
    }
  }
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