結果

問題 No.798 コレクション
ユーザー ikdikd
提出日時 2019-03-16 19:55:50
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 423 bytes
コンパイル時間 446 ms
コンパイル使用メモリ 10,900 KB
実行使用メモリ 123,584 KB
最終ジャッジ日時 2023-09-14 15:27:53
合計ジャッジ時間 12,737 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
7,972 KB
testcase_01 AC 16 ms
7,856 KB
testcase_02 AC 16 ms
7,896 KB
testcase_03 AC 16 ms
7,916 KB
testcase_04 AC 16 ms
7,888 KB
testcase_05 AC 16 ms
7,904 KB
testcase_06 AC 16 ms
7,736 KB
testcase_07 AC 16 ms
7,820 KB
testcase_08 AC 16 ms
7,816 KB
testcase_09 AC 16 ms
7,740 KB
testcase_10 AC 16 ms
7,916 KB
testcase_11 AC 16 ms
7,900 KB
testcase_12 AC 16 ms
7,796 KB
testcase_13 AC 1,318 ms
52,388 KB
testcase_14 TLE -
testcase_15 AC 1,871 ms
70,324 KB
testcase_16 AC 915 ms
35,360 KB
testcase_17 AC 1,367 ms
54,116 KB
testcase_18 TLE -
testcase_19 TLE -
testcase_20 AC 898 ms
40,648 KB
testcase_21 AC 900 ms
37,016 KB
testcase_22 TLE -
testcase_23 AC 17 ms
7,740 KB
testcase_24 TLE -
testcase_25 TLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

"""a"""
n = int(input())
ab = [list(map(int, input().split())) for _ in range(n)]
ab.sort(key=lambda x: x[1], reverse=True)
dp = [[100000000000000000 for _ in range(n + 1)] for __ in range(n + 1)]
dp[0][0] = 0
for i in range(0, n):
    for j in range(0, i + 1):
        dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + ab[i][0] + ab[i][1] * (i - j))
        dp[i + 1][j + 1] = min(dp[i + 1][j + 1], dp[i][j])
print(dp[n][n//3])
0