結果

問題 No.798 コレクション
ユーザー neterukunneterukun
提出日時 2020-07-26 13:40:38
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 603 bytes
コンパイル時間 289 ms
コンパイル使用メモリ 87,184 KB
実行使用メモリ 100,616 KB
最終ジャッジ日時 2023-09-10 23:16:12
合計ジャッジ時間 5,091 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,516 KB
testcase_01 AC 74 ms
71,200 KB
testcase_02 AC 75 ms
71,244 KB
testcase_03 WA -
testcase_04 AC 76 ms
71,324 KB
testcase_05 AC 74 ms
71,560 KB
testcase_06 AC 76 ms
71,488 KB
testcase_07 AC 75 ms
71,408 KB
testcase_08 AC 75 ms
71,300 KB
testcase_09 AC 75 ms
71,464 KB
testcase_10 AC 75 ms
71,512 KB
testcase_11 AC 75 ms
71,388 KB
testcase_12 AC 75 ms
71,552 KB
testcase_13 AC 183 ms
78,456 KB
testcase_14 AC 207 ms
100,220 KB
testcase_15 AC 191 ms
97,100 KB
testcase_16 AC 138 ms
83,184 KB
testcase_17 AC 161 ms
78,492 KB
testcase_18 AC 252 ms
100,372 KB
testcase_19 AC 209 ms
100,504 KB
testcase_20 AC 141 ms
82,892 KB
testcase_21 AC 133 ms
83,760 KB
testcase_22 AC 189 ms
97,036 KB
testcase_23 AC 73 ms
71,348 KB
testcase_24 AC 212 ms
100,616 KB
testcase_25 AC 213 ms
100,344 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from operator import itemgetter


n = int(input())
info = [list(map(int, input().split())) for i in range(n)]
INF = 10 ** 18


info.sort(key=itemgetter(1), reverse=True)
dp = [[INF] * (n + 1) for i in range(n + 1)]
dp[0][0] = 0

cnt = 0
for i in range(n):
    if i % 2 == 0:
        cnt += 1
    else:
        cnt += 2
    if cnt >= n:
        ind = i
        break

for i in range(n):
    # j番目のitemを選ぶ
    val = dp[i][0]
    for j in range(n):
        a, b = info[j]
        val = min(val, dp[i][j])
        dp[i + 1][j + 1] = min(val + a + b * i, dp[i + 1][j + 1])

print(dp[ind + 1][-1])
0