結果

問題 No.798 コレクション
ユーザー neterukunneterukun
提出日時 2020-07-26 13:38:06
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 585 bytes
コンパイル時間 1,870 ms
コンパイル使用メモリ 86,748 KB
実行使用メモリ 97,580 KB
最終ジャッジ日時 2023-09-10 23:11:38
合計ジャッジ時間 6,432 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 80 ms
75,552 KB
testcase_01 AC 83 ms
71,228 KB
testcase_02 AC 80 ms
70,964 KB
testcase_03 WA -
testcase_04 AC 80 ms
71,032 KB
testcase_05 AC 81 ms
71,368 KB
testcase_06 AC 81 ms
71,252 KB
testcase_07 AC 80 ms
71,260 KB
testcase_08 AC 80 ms
71,320 KB
testcase_09 AC 83 ms
70,944 KB
testcase_10 AC 80 ms
71,248 KB
testcase_11 AC 80 ms
71,368 KB
testcase_12 AC 80 ms
70,856 KB
testcase_13 TLE -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
権限があれば一括ダウンロードができます

ソースコード

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を選ぶ
    for j in range(n):
        a, b = info[j]
        val = min(dp[i][0:j + 1])
        dp[i + 1][j + 1] = min(val + a + b * i, dp[i + 1][j + 1])

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