結果

問題 No.1430 Coup de Coupon
ユーザー mkawa2mkawa2
提出日時 2021-03-14 14:50:48
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 1,355 bytes
コンパイル時間 139 ms
コンパイル使用メモリ 82,092 KB
実行使用メモリ 274,212 KB
最終ジャッジ日時 2024-04-23 22:31:03
合計ジャッジ時間 4,784 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
52,736 KB
testcase_01 AC 35 ms
52,096 KB
testcase_02 RE -
testcase_03 RE -
testcase_04 RE -
testcase_05 AC 44 ms
66,176 KB
testcase_06 RE -
testcase_07 RE -
testcase_08 AC 55 ms
71,572 KB
testcase_09 AC 170 ms
97,664 KB
testcase_10 AC 231 ms
115,456 KB
testcase_11 AC 307 ms
134,356 KB
testcase_12 AC 380 ms
154,660 KB
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 AC 450 ms
174,032 KB
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 AC 32 ms
52,480 KB
testcase_23 AC 40 ms
61,312 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 j<len(t1):chmin(i+1,j+1,pre+max(0,p-t1[j]))
        if i-j<len(t2):chmin(i+1,j,pre+(100-t2[i-j])*p//100)
# p2D(dp)

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