結果

問題 No.798 コレクション
ユーザー kohei2019kohei2019
提出日時 2022-04-12 15:21:28
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 294 ms / 2,000 ms
コード長 474 bytes
コンパイル時間 889 ms
コンパイル使用メモリ 86,936 KB
実行使用メモリ 139,440 KB
最終ジャッジ日時 2023-08-22 20:11:48
合計ジャッジ時間 6,272 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,248 KB
testcase_01 AC 73 ms
71,268 KB
testcase_02 AC 75 ms
71,232 KB
testcase_03 AC 73 ms
71,088 KB
testcase_04 AC 73 ms
70,900 KB
testcase_05 AC 71 ms
70,768 KB
testcase_06 AC 71 ms
71,148 KB
testcase_07 AC 71 ms
71,088 KB
testcase_08 AC 72 ms
71,052 KB
testcase_09 AC 73 ms
71,052 KB
testcase_10 AC 73 ms
71,212 KB
testcase_11 AC 71 ms
71,224 KB
testcase_12 AC 72 ms
71,052 KB
testcase_13 AC 166 ms
90,988 KB
testcase_14 AC 190 ms
103,244 KB
testcase_15 AC 186 ms
101,736 KB
testcase_16 AC 131 ms
83,164 KB
testcase_17 AC 163 ms
91,404 KB
testcase_18 AC 293 ms
135,848 KB
testcase_19 AC 248 ms
119,656 KB
testcase_20 AC 156 ms
91,652 KB
testcase_21 AC 139 ms
82,560 KB
testcase_22 AC 212 ms
105,184 KB
testcase_23 AC 70 ms
71,224 KB
testcase_24 AC 181 ms
100,172 KB
testcase_25 AC 294 ms
139,440 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
lsAB = []
for i in range(N):
    A,B = map(int,input().split())
    lsAB.append([A,B])
lsAB.sort(key=lambda x:-x[1])
INF = float('INF')
if N%3==0:
    M = 2*(N//3)
elif N % 3 == 1:
    M = 2*(N//3)+1
else:
    M = 2*(N//3)+2
dp = [[INF]*(N) for i in range(M)]
for i in range(N):
    dp[0][i] = lsAB[i][0]
for i in range(1,M):
    rm = INF
    for j in range(N):
        dp[i][j]=rm+lsAB[j][0]+lsAB[j][1]*i
        rm = min(rm,dp[i-1][j])
print(min(dp[-1]))
0