結果

問題 No.798 コレクション
ユーザー hogeandfugahogeandfuga
提出日時 2019-03-16 00:35:28
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 409 bytes
コンパイル時間 75 ms
コンパイル使用メモリ 10,788 KB
実行使用メモリ 122,340 KB
最終ジャッジ日時 2023-09-14 14:53:55
合計ジャッジ時間 13,358 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,888 KB
testcase_01 AC 16 ms
7,808 KB
testcase_02 AC 16 ms
7,828 KB
testcase_03 AC 16 ms
7,844 KB
testcase_04 AC 16 ms
7,796 KB
testcase_05 AC 16 ms
7,792 KB
testcase_06 AC 16 ms
7,812 KB
testcase_07 AC 16 ms
7,776 KB
testcase_08 AC 16 ms
7,812 KB
testcase_09 AC 15 ms
7,788 KB
testcase_10 AC 16 ms
7,872 KB
testcase_11 AC 16 ms
7,844 KB
testcase_12 AC 16 ms
7,852 KB
testcase_13 AC 1,571 ms
51,512 KB
testcase_14 TLE -
testcase_15 TLE -
testcase_16 AC 1,006 ms
34,920 KB
testcase_17 AC 1,624 ms
53,440 KB
testcase_18 TLE -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
権限があれば一括ダウンロードができます

ソースコード

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