結果

問題 No.798 コレクション
ユーザー AEnAEn
提出日時 2023-04-17 22:41:13
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 162 ms / 2,000 ms
コード長 391 bytes
コンパイル時間 265 ms
コンパイル使用メモリ 82,436 KB
実行使用メモリ 77,404 KB
最終ジャッジ日時 2024-04-21 00:27:09
合計ジャッジ時間 3,219 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
54,104 KB
testcase_01 AC 36 ms
53,896 KB
testcase_02 AC 37 ms
53,976 KB
testcase_03 AC 36 ms
53,276 KB
testcase_04 AC 39 ms
52,312 KB
testcase_05 AC 38 ms
52,536 KB
testcase_06 AC 35 ms
52,408 KB
testcase_07 AC 35 ms
53,612 KB
testcase_08 AC 36 ms
52,616 KB
testcase_09 AC 38 ms
53,260 KB
testcase_10 AC 36 ms
52,204 KB
testcase_11 AC 36 ms
53,208 KB
testcase_12 AC 36 ms
52,768 KB
testcase_13 AC 89 ms
76,700 KB
testcase_14 AC 125 ms
77,032 KB
testcase_15 AC 126 ms
76,928 KB
testcase_16 AC 77 ms
76,356 KB
testcase_17 AC 95 ms
76,892 KB
testcase_18 AC 162 ms
77,096 KB
testcase_19 AC 148 ms
77,404 KB
testcase_20 AC 97 ms
76,804 KB
testcase_21 AC 92 ms
76,580 KB
testcase_22 AC 131 ms
77,160 KB
testcase_23 AC 36 ms
52,660 KB
testcase_24 AC 110 ms
76,668 KB
testcase_25 AC 160 ms
77,156 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
item = [list(map(int, input().split())) for _ in range(N)]
item.sort(reverse=True,key = lambda x:x[1])

dp = [float('inf')]*(N-N//3+1)
dp[0] = 0
for i in range(N):
    a,b = item[i]
    ndp = [float('inf')]*(N-N//3+1)
    ndp[0] = 0
    for j in range(1,N-N//3+1):
        ndp[j] = min(dp[j],ndp[j])
        ndp[j] = min(ndp[j],dp[j-1]+a+b*(j-1))
    dp = ndp
print(dp[-1])
0