結果

問題 No.798 コレクション
ユーザー stngstng
提出日時 2022-07-02 13:18:54
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 221 ms / 2,000 ms
コード長 374 bytes
コンパイル時間 937 ms
コンパイル使用メモリ 86,992 KB
実行使用メモリ 102,872 KB
最終ジャッジ日時 2023-08-18 04:12:26
合計ジャッジ時間 5,350 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,388 KB
testcase_01 AC 72 ms
71,068 KB
testcase_02 AC 73 ms
71,300 KB
testcase_03 AC 74 ms
71,260 KB
testcase_04 AC 72 ms
71,188 KB
testcase_05 AC 72 ms
70,988 KB
testcase_06 AC 74 ms
71,336 KB
testcase_07 AC 73 ms
71,080 KB
testcase_08 AC 74 ms
71,364 KB
testcase_09 AC 74 ms
71,440 KB
testcase_10 AC 74 ms
71,280 KB
testcase_11 AC 73 ms
71,252 KB
testcase_12 AC 73 ms
71,140 KB
testcase_13 AC 147 ms
81,116 KB
testcase_14 AC 175 ms
100,164 KB
testcase_15 AC 151 ms
80,864 KB
testcase_16 AC 129 ms
85,636 KB
testcase_17 AC 145 ms
81,184 KB
testcase_18 AC 189 ms
102,872 KB
testcase_19 AC 177 ms
101,636 KB
testcase_20 AC 129 ms
85,516 KB
testcase_21 AC 123 ms
85,364 KB
testcase_22 AC 151 ms
81,040 KB
testcase_23 AC 73 ms
71,404 KB
testcase_24 AC 219 ms
102,772 KB
testcase_25 AC 221 ms
102,672 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
ab = [[int(i) for i in input().split()] for j in range(n)]

ab.sort(reverse=True, key=lambda x: x[1])
INF = 10**12

dp = [[INF]*(n+1) for i in range(n+1)]

dp[0][0] = 0

for i in range(1,n+1):
    for j in range(n+1):
        dp[i][j] = min(dp[i-1][j-1],dp[i-1][j]+ab[i-1][0]+ab[i-1][1]*(i-j-1))
        #print(i,j,ab[i-1][0],ab[i-1][1])

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