結果

問題 No.1430 Coup de Coupon
ユーザー mkawa2mkawa2
提出日時 2021-03-14 14:53:50
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 1,369 bytes
コンパイル時間 161 ms
コンパイル使用メモリ 82,688 KB
実行使用メモリ 273,104 KB
最終ジャッジ日時 2024-04-23 22:33:43
合計ジャッジ時間 6,114 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
52,608 KB
testcase_01 AC 41 ms
52,736 KB
testcase_02 AC 40 ms
52,096 KB
testcase_03 AC 50 ms
61,056 KB
testcase_04 AC 61 ms
68,248 KB
testcase_05 AC 52 ms
66,304 KB
testcase_06 AC 495 ms
272,640 KB
testcase_07 AC 614 ms
273,104 KB
testcase_08 AC 63 ms
71,640 KB
testcase_09 AC 193 ms
97,536 KB
testcase_10 AC 275 ms
115,840 KB
testcase_11 AC 360 ms
134,016 KB
testcase_12 AC 436 ms
154,368 KB
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 AC 511 ms
173,852 KB
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 AC 42 ms
52,224 KB
testcase_23 AC 50 ms
61,952 KB
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
権限があれば一括ダウンロードができます

ソースコード

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(len(t1),-1,-1):
        pre=dp[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