結果

問題 No.1430 Coup de Coupon
ユーザー so4649so4649
提出日時 2021-03-14 15:34:54
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 498 ms / 2,000 ms
コード長 859 bytes
コンパイル時間 337 ms
コンパイル使用メモリ 82,716 KB
実行使用メモリ 272,868 KB
最終ジャッジ日時 2024-04-23 23:08:18
合計ジャッジ時間 7,141 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
52,224 KB
testcase_01 AC 40 ms
52,480 KB
testcase_02 AC 39 ms
52,096 KB
testcase_03 AC 443 ms
272,256 KB
testcase_04 AC 44 ms
64,348 KB
testcase_05 AC 42 ms
62,928 KB
testcase_06 AC 360 ms
272,124 KB
testcase_07 AC 354 ms
272,868 KB
testcase_08 AC 60 ms
69,020 KB
testcase_09 AC 172 ms
97,408 KB
testcase_10 AC 217 ms
107,592 KB
testcase_11 AC 315 ms
131,048 KB
testcase_12 AC 332 ms
153,076 KB
testcase_13 AC 373 ms
175,604 KB
testcase_14 AC 419 ms
195,344 KB
testcase_15 AC 451 ms
215,156 KB
testcase_16 AC 487 ms
223,148 KB
testcase_17 AC 498 ms
246,100 KB
testcase_18 AC 378 ms
174,276 KB
testcase_19 AC 421 ms
176,920 KB
testcase_20 AC 176 ms
128,148 KB
testcase_21 AC 134 ms
105,768 KB
testcase_22 AC 34 ms
52,468 KB
testcase_23 AC 34 ms
53,660 KB
testcase_24 AC 53 ms
66,144 KB
testcase_25 AC 104 ms
89,856 KB
testcase_26 AC 88 ms
82,652 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

n,c = map(int,input().split())
p = [int(input()) for i in range(n)]

p.sort(reverse=True)
hiki = []
wari = []
for i in range(c):
    t,x = map(int,input().split())
    if t == 1:
        hiki.append(x)
    else:
        wari.append(x)
hiki.sort(reverse=True)
wari.sort(reverse=True)

if len(hiki)+len(wari) < n:
    for i in range(n-c):
        hiki.append(0)
        wari.append(0)
    c = n


INF = 10**15
# i番目で、既にhikiをj枚使っている時の値段
dp = [[INF]*(len(hiki)+1) for i in range(n+1)]
dp[0][0] = 0

for i in range(n):
    for j in range(min(i,len(hiki))+1):
        if j < len(hiki):
            dp[i+1][j+1] = min(dp[i+1][j+1],dp[i][j]+max(0,p[i]-hiki[j]))
        if i-j < len(wari):
            dp[i+1][j] = min(dp[i+1][j],dp[i][j]+p[i]//100*(100-wari[i-j]))

ans = min(dp[n])
print(ans)
0