結果

問題 No.798 コレクション
ユーザー vwxyzvwxyz
提出日時 2022-04-09 20:54:16
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,804 ms / 2,000 ms
コード長 369 bytes
コンパイル時間 96 ms
コンパイル使用メモリ 10,988 KB
実行使用メモリ 8,628 KB
最終ジャッジ日時 2023-08-20 00:53:23
合計ジャッジ時間 14,918 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
7,884 KB
testcase_01 AC 15 ms
7,824 KB
testcase_02 AC 15 ms
7,992 KB
testcase_03 AC 16 ms
7,780 KB
testcase_04 AC 16 ms
7,840 KB
testcase_05 AC 16 ms
7,832 KB
testcase_06 AC 16 ms
7,828 KB
testcase_07 AC 15 ms
7,860 KB
testcase_08 AC 16 ms
7,788 KB
testcase_09 AC 16 ms
7,988 KB
testcase_10 AC 15 ms
7,824 KB
testcase_11 AC 15 ms
7,868 KB
testcase_12 AC 14 ms
7,836 KB
testcase_13 AC 757 ms
8,308 KB
testcase_14 AC 1,249 ms
8,504 KB
testcase_15 AC 1,123 ms
8,412 KB
testcase_16 AC 500 ms
8,388 KB
testcase_17 AC 819 ms
8,364 KB
testcase_18 AC 1,744 ms
8,296 KB
testcase_19 AC 1,347 ms
8,500 KB
testcase_20 AC 546 ms
8,400 KB
testcase_21 AC 476 ms
8,252 KB
testcase_22 AC 1,120 ms
8,484 KB
testcase_23 AC 15 ms
7,880 KB
testcase_24 AC 1,700 ms
8,452 KB
testcase_25 AC 1,804 ms
8,628 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
readline=sys.stdin.readline

N=int(readline())
A,B=[],[]
for i in range(N):
    a,b=map(int,readline().split())
    A.append(a)
    B.append(b)
inf=1<<60
NN=N-N//3
dp=[inf]*(NN+1)
dp[0]=0
for i in sorted([i for i in range(N)],key=lambda i:B[i],reverse=True):
    for n in range(NN,0,-1):
        dp[n]=min(dp[n],dp[n-1]+A[i]+B[i]*(n-1))
ans=dp[NN]
print(ans)
0