結果

問題 No.710 チーム戦
ユーザー ikdikd
提出日時 2018-07-16 02:07:18
言語 Nim
(2.0.0)
結果
AC  
実行時間 40 ms / 3,000 ms
コード長 549 bytes
コンパイル時間 3,308 ms
コンパイル使用メモリ 68,512 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-13 18:33:44
合計ジャッジ時間 4,910 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
4,376 KB
testcase_01 AC 3 ms
4,376 KB
testcase_02 AC 34 ms
4,376 KB
testcase_03 AC 33 ms
4,380 KB
testcase_04 AC 35 ms
4,376 KB
testcase_05 AC 32 ms
4,376 KB
testcase_06 AC 33 ms
4,380 KB
testcase_07 AC 34 ms
4,376 KB
testcase_08 AC 35 ms
4,376 KB
testcase_09 AC 34 ms
4,384 KB
testcase_10 AC 32 ms
4,376 KB
testcase_11 AC 33 ms
4,376 KB
testcase_12 AC 35 ms
4,380 KB
testcase_13 AC 34 ms
4,380 KB
testcase_14 AC 34 ms
4,376 KB
testcase_15 AC 33 ms
4,376 KB
testcase_16 AC 34 ms
4,376 KB
testcase_17 AC 32 ms
4,376 KB
testcase_18 AC 33 ms
4,376 KB
testcase_19 AC 35 ms
4,376 KB
testcase_20 AC 33 ms
4,380 KB
testcase_21 AC 34 ms
4,380 KB
testcase_22 AC 21 ms
4,376 KB
testcase_23 AC 21 ms
4,380 KB
testcase_24 AC 40 ms
4,376 KB
testcase_25 AC 2 ms
4,380 KB
testcase_26 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import strutils, sequtils, algorithm

var
  n=stdin.readLine.parseInt
  dp=newSeq[int](1000*100+1)
  # dp[t]:=sum_{i in I}(A_i)=tを満たすIに対して、max_{I}(\sum_{i in I}(B_i))
  sb=0

fill(dp, -1)
dp[0]=0
for _ in 0..<n:
  var
    args=stdin.readLine.split.map(parseInt)
    (a, b)=(args[0], args[1])
  sb+=b
  for t in countdown(1000*100, 0):
    if dp[t]<0:
      continue
    if t+a<dp.len:
      dp[t+a]=max(dp[t+a], dp[t]+b)

var mn=1_000_000_000
for t in 0..1000*100:
  if dp[t]<0:
    continue
  mn=min(mn, max(t, sb-dp[t]))

echo mn
0