結果

問題 No.798 コレクション
ユーザー htkb
提出日時 2019-03-27 21:40:17
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 1,321 ms / 2,000 ms
コード長 382 bytes
コンパイル時間 300 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 11,136 KB
最終ジャッジ日時 2024-10-11 06:13:47
合計ジャッジ時間 11,474 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
from math import ceil
from operator import itemgetter
N = int(input())
items = sorted((tuple(map(int, l.split())) for l in sys.stdin), key=itemgetter(1), reverse=True)
count = ceil(2/3*N)
inf = 10**12
dp = [0] + [inf]*count

for i, (a, b) in enumerate(items, start=1):
    for j in range(min(count, i), 0, -1):
        dp[j] = min(dp[j], dp[j-1]+a+b*(j-1))

print(dp[-1])
0