結果

問題 No.1430 Coup de Coupon
ユーザー mkawa2mkawa2
提出日時 2021-03-14 14:59:51
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 480 ms / 2,000 ms
コード長 1,397 bytes
コンパイル時間 269 ms
コンパイル使用メモリ 82,172 KB
実行使用メモリ 272,532 KB
最終ジャッジ日時 2024-04-23 22:40:22
合計ジャッジ時間 6,140 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 33 ms
53,688 KB
testcase_01 AC 34 ms
52,620 KB
testcase_02 AC 34 ms
53,196 KB
testcase_03 AC 41 ms
62,752 KB
testcase_04 AC 46 ms
67,176 KB
testcase_05 AC 44 ms
66,888 KB
testcase_06 AC 329 ms
272,516 KB
testcase_07 AC 342 ms
272,532 KB
testcase_08 AC 57 ms
72,428 KB
testcase_09 AC 150 ms
97,792 KB
testcase_10 AC 227 ms
115,532 KB
testcase_11 AC 243 ms
127,896 KB
testcase_12 AC 346 ms
151,244 KB
testcase_13 AC 345 ms
173,952 KB
testcase_14 AC 383 ms
195,700 KB
testcase_15 AC 425 ms
215,072 KB
testcase_16 AC 454 ms
232,960 KB
testcase_17 AC 480 ms
252,636 KB
testcase_18 AC 346 ms
173,880 KB
testcase_19 AC 349 ms
173,904 KB
testcase_20 AC 166 ms
127,404 KB
testcase_21 AC 61 ms
71,612 KB
testcase_22 AC 35 ms
53,412 KB
testcase_23 AC 35 ms
53,976 KB
testcase_24 AC 51 ms
66,084 KB
testcase_25 AC 51 ms
66,664 KB
testcase_26 AC 83 ms
83,132 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

sys.setrecursionlimit(10**6)
int1 = lambda x: int(x)-1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.buffer.readline())
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def LI1(): return list(map(int1, sys.stdin.buffer.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
def BI(): return sys.stdin.buffer.readline().rstrip()
def SI(): return sys.stdin.buffer.readline().rstrip().decode()
# dij = [(0, 1), (-1, 0), (0, -1), (1, 0)]
dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)]
inf = 10**16
# md = 998244353
md = 10**9+7

n, c = LI()
pp = [II() for _ in range(n)]
t1, t2 = [], []
for _ in range(c):
    t, x = LI()
    if t == 1: t1.append(x)
    else: t2.append(x)

pp.sort(reverse=True)
t1.sort(reverse=True)
t2.sort(reverse=True)

ans=0
for _ in range(n-c):
    ans+=pp.pop()

def chmin(i,j,val):
    if val<dp[i][j]:dp[i][j]=val

# dp[j]...t1をj枚使った時の最小金額
dp=[[inf]*(len(t1)+1) for _ in range(len(pp)+1)]
dp[0][0]=0
for i,p in enumerate(pp):
    for j in range(min(i,len(t1)),-1,-1):
        pre=dp[i][j]
        # print(i,j)
        if t1 and j<len(t1):chmin(i+1,j+1,pre+max(0,p-t1[j]))
        if t2 and i-j<len(t2):chmin(i+1,j,pre+(100-t2[i-j])*p//100)
# p2D(dp)

print(ans+min(dp[-1]))
0