結果

問題 No.1430 Coup de Coupon
ユーザー mkawa2mkawa2
提出日時 2021-03-14 14:58:48
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,398 bytes
コンパイル時間 192 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 272,708 KB
最終ジャッジ日時 2024-04-23 22:39:13
合計ジャッジ時間 3,607 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
52,352 KB
testcase_01 WA -
testcase_02 AC 37 ms
52,352 KB
testcase_03 AC 40 ms
61,056 KB
testcase_04 AC 45 ms
66,688 KB
testcase_05 AC 45 ms
66,432 KB
testcase_06 AC 223 ms
272,708 KB
testcase_07 AC 229 ms
272,304 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 34 ms
53,120 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
権限があれば一括ダウンロードができます

ソースコード

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)),i-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