結果

問題 No.798 コレクション
ユーザー pasoconhoshiipasoconhoshii
提出日時 2019-03-16 10:51:26
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 548 bytes
コンパイル時間 263 ms
コンパイル使用メモリ 87,164 KB
実行使用メモリ 102,492 KB
最終ジャッジ日時 2023-09-14 15:07:35
合計ジャッジ時間 4,462 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
71,388 KB
testcase_01 AC 69 ms
71,156 KB
testcase_02 AC 70 ms
71,352 KB
testcase_03 AC 71 ms
71,408 KB
testcase_04 AC 69 ms
71,284 KB
testcase_05 AC 68 ms
71,176 KB
testcase_06 AC 69 ms
71,440 KB
testcase_07 AC 69 ms
71,444 KB
testcase_08 AC 69 ms
71,032 KB
testcase_09 AC 69 ms
71,280 KB
testcase_10 AC 70 ms
71,336 KB
testcase_11 AC 70 ms
71,204 KB
testcase_12 AC 72 ms
71,044 KB
testcase_13 AC 144 ms
80,728 KB
testcase_14 AC 184 ms
100,344 KB
testcase_15 AC 172 ms
96,856 KB
testcase_16 AC 130 ms
85,364 KB
testcase_17 AC 150 ms
80,860 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 133 ms
85,008 KB
testcase_21 AC 125 ms
85,292 KB
testcase_22 WA -
testcase_23 AC 70 ms
71,408 KB
testcase_24 AC 237 ms
102,392 KB
testcase_25 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
AB = [ tuple([int(j) for j in input().split()]) for _ in range(N)]
AB = sorted(AB, key=lambda x:x[1], reverse=True)

dp = [ [ 10**10 ]*(N+1) for _ in range(N+1)] # i,j iコメまで集めて、j 個タダでもらった
dp[0][0] = 0

for i in range(1,N+1):
    for j in range(0,N):
        dp[i][j] = min ( dp[i][j], dp[i-1][j] + AB[i-1][0] + AB[i-1][1]* (i-j-1))   
        dp[i][j+1] = min( dp[i-1][j], dp[i][j+1]) # タダで買う
    dp[i][N] = min(dp[i][N], dp[i-1][N] + AB[i-1][0] + AB[i-1][1]*(i-j-1))


print(dp[N][N//3])
0