結果

問題 No.798 コレクション
ユーザー rookzenorookzeno
提出日時 2019-03-16 12:33:46
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,460 ms / 2,000 ms
コード長 446 bytes
コンパイル時間 94 ms
コンパイル使用メモリ 10,856 KB
実行使用メモリ 65,552 KB
最終ジャッジ日時 2023-09-14 15:13:04
合計ジャッジ時間 12,208 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
7,780 KB
testcase_01 AC 17 ms
7,808 KB
testcase_02 AC 16 ms
7,808 KB
testcase_03 AC 16 ms
7,776 KB
testcase_04 AC 16 ms
7,880 KB
testcase_05 AC 16 ms
7,896 KB
testcase_06 AC 16 ms
7,888 KB
testcase_07 AC 16 ms
7,732 KB
testcase_08 AC 16 ms
7,880 KB
testcase_09 AC 16 ms
7,860 KB
testcase_10 AC 16 ms
7,932 KB
testcase_11 AC 16 ms
7,876 KB
testcase_12 AC 15 ms
7,880 KB
testcase_13 AC 647 ms
30,760 KB
testcase_14 AC 1,073 ms
47,084 KB
testcase_15 AC 891 ms
41,088 KB
testcase_16 AC 403 ms
21,728 KB
testcase_17 AC 655 ms
31,864 KB
testcase_18 AC 1,398 ms
65,552 KB
testcase_19 AC 1,100 ms
53,652 KB
testcase_20 AC 434 ms
25,384 KB
testcase_21 AC 378 ms
23,088 KB
testcase_22 AC 892 ms
44,940 KB
testcase_23 AC 16 ms
7,816 KB
testcase_24 AC 1,429 ms
19,164 KB
testcase_25 AC 1,460 ms
19,384 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
sys.setrecursionlimit(20000000)
input = sys.stdin.readline
n = int(input())
a = [list(map(int,input().split())) for i in range(n)]
a.sort(key= lambda x: -x[1])
dp = [[float("inf")]*(n//3+1) for i in range(n+1)]
dp[0][0] = 0
for i in range(n):
        dp[i+1][0] = dp[i][0]+a[i][0]+a[i][1]*(i)
        for j in range(n//3):
                dp[i+1][j+1] = min(dp[i+1][j+1],dp[i][j],dp[i][j+1]+a[i][0]+a[i][1]*(i-j-1))

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