結果

問題 No.798 コレクション
ユーザー pasoconhoshiipasoconhoshii
提出日時 2019-03-16 10:45:30
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 606 bytes
コンパイル時間 272 ms
コンパイル使用メモリ 86,860 KB
実行使用メモリ 102,564 KB
最終ジャッジ日時 2023-09-14 15:07:11
合計ジャッジ時間 4,720 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,404 KB
testcase_01 AC 73 ms
71,448 KB
testcase_02 AC 75 ms
71,408 KB
testcase_03 AC 79 ms
71,392 KB
testcase_04 AC 74 ms
71,380 KB
testcase_05 AC 74 ms
71,500 KB
testcase_06 AC 73 ms
71,420 KB
testcase_07 AC 72 ms
71,144 KB
testcase_08 AC 75 ms
71,352 KB
testcase_09 AC 74 ms
71,404 KB
testcase_10 AC 75 ms
71,344 KB
testcase_11 AC 75 ms
71,376 KB
testcase_12 AC 75 ms
71,216 KB
testcase_13 AC 150 ms
80,780 KB
testcase_14 AC 183 ms
100,220 KB
testcase_15 AC 173 ms
97,096 KB
testcase_16 AC 133 ms
85,424 KB
testcase_17 AC 148 ms
80,836 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 137 ms
85,568 KB
testcase_21 AC 134 ms
85,448 KB
testcase_22 WA -
testcase_23 AC 77 ms
71,324 KB
testcase_24 AC 237 ms
102,320 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+1):
        if j > 0:
            dp[i][j] = min( dp[i-1][j-1], dp[i][j], # タダで買う
                            dp[i-1][j] + AB[i-1][0] + AB[i-1][1]* (i-j-1))

        if j == 0:
            dp[i][j] = min ( dp[i][j], 
               dp[i-1][j] + AB[i-1][0] + AB[i-1][1]* (i-j-1))

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