結果

問題 No.798 コレクション
ユーザー hogeandfugahogeandfuga
提出日時 2019-03-16 00:36:07
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 319 ms / 2,000 ms
コード長 409 bytes
コンパイル時間 285 ms
コンパイル使用メモリ 87,108 KB
実行使用メモリ 158,084 KB
最終ジャッジ日時 2023-09-14 14:53:30
合計ジャッジ時間 5,196 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
70,772 KB
testcase_01 AC 70 ms
71,244 KB
testcase_02 AC 70 ms
71,276 KB
testcase_03 AC 70 ms
71,304 KB
testcase_04 AC 71 ms
71,280 KB
testcase_05 AC 71 ms
71,208 KB
testcase_06 AC 71 ms
70,952 KB
testcase_07 AC 71 ms
71,244 KB
testcase_08 AC 72 ms
71,284 KB
testcase_09 AC 72 ms
71,152 KB
testcase_10 AC 71 ms
70,764 KB
testcase_11 AC 69 ms
70,996 KB
testcase_12 AC 70 ms
71,000 KB
testcase_13 AC 246 ms
104,156 KB
testcase_14 AC 255 ms
133,892 KB
testcase_15 AC 214 ms
112,808 KB
testcase_16 AC 133 ms
85,548 KB
testcase_17 AC 196 ms
104,488 KB
testcase_18 AC 319 ms
158,084 KB
testcase_19 AC 274 ms
136,416 KB
testcase_20 AC 170 ms
94,848 KB
testcase_21 AC 163 ms
94,312 KB
testcase_22 AC 236 ms
112,832 KB
testcase_23 AC 73 ms
71,300 KB
testcase_24 AC 225 ms
125,736 KB
testcase_25 AC 289 ms
141,048 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
t = [(0, 0)] +  sorted([tuple(map(int, input().split())) for _ in range(n)], key=lambda x:-x[1])
inf = float("inf")

dp = [[inf]*(n+2) for _ in range(n+1)]
dp[0][0] = 0

for i in range(1, n+1):
    dp[i][0] = dp[i-1][0]+t[i][0]+t[i][1]*(i-1)

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

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