結果

問題 No.798 コレクション
ユーザー pasoconhoshiipasoconhoshii
提出日時 2019-03-16 10:43:49
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 606 bytes
コンパイル時間 719 ms
コンパイル使用メモリ 10,688 KB
実行使用メモリ 121,056 KB
最終ジャッジ日時 2023-09-14 15:07:17
合計ジャッジ時間 6,195 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,788 KB
testcase_01 AC 16 ms
7,732 KB
testcase_02 AC 17 ms
7,840 KB
testcase_03 AC 16 ms
7,896 KB
testcase_04 AC 16 ms
7,728 KB
testcase_05 AC 16 ms
7,892 KB
testcase_06 AC 15 ms
7,780 KB
testcase_07 AC 16 ms
7,740 KB
testcase_08 AC 16 ms
7,848 KB
testcase_09 AC 16 ms
7,760 KB
testcase_10 AC 16 ms
7,732 KB
testcase_11 AC 16 ms
7,728 KB
testcase_12 AC 16 ms
7,772 KB
testcase_13 TLE -
testcase_14 TLE -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
AB = [ tuple([int(j) for j in input().split()]) for _ in range(N)]
AB = sorted(AB, key=lambda x:x[1], reverse=True)

dp = [ [ 10**10 ]*(N+1) for _ in range(N+1)] # i,j iコメまで集めて、j 個タダでもらった
dp[0][0] = 0

for i in range(1,N+1):
    for j in range(0,N+1):
        if j > 0:
            dp[i][j] = min( dp[i-1][j-1], dp[i][j], # タダで買う
                            dp[i-1][j] + AB[i-1][0] + AB[i-1][1]* (i-j-1))

        if j == 0:
            dp[i][j] = min ( dp[i][j], 
               dp[i-1][j] + AB[i-1][0] + AB[i-1][1]* (i-j-1))

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