結果

問題 No.1430 Coup de Coupon
ユーザー tcltktcltk
提出日時 2021-06-26 07:07:32
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 340 ms / 2,000 ms
コード長 1,154 bytes
コンパイル時間 320 ms
コンパイル使用メモリ 82,388 KB
実行使用メモリ 90,280 KB
最終ジャッジ日時 2024-06-25 07:51:46
合計ジャッジ時間 7,108 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 27
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env python3
# from typing import *

import sys
import io
import math
import collections
import decimal
import itertools
import bisect
import heapq


def input():
    return sys.stdin.readline()[:-1]


# sys.setrecursionlimit(1000000)

# _INPUT = """1 2
# 2000
# 1 500
# 2 30
# """
# sys.stdin = io.StringIO(_INPUT)

N, C = map(int, input().split())
P = [int(input()) for _ in range(N)]
Coupons1 = []
Coupons2 = []
for _ in range(C):
    t, x = map(int, input().split())
    if t == 1:
        Coupons1.append(x)
    else:
        Coupons2.append(x)
P.sort(reverse=True)
Coupons1.sort(reverse=True)
Coupons2.sort(reverse=True)
C1 = len(Coupons1)
C2 = len(Coupons2)

dp = [10**10] * (C1+1)
dp[0] = 0
for i in range(min(N, C)):

    dp1 = [10**10] * (C1+1)

    for k in range(C1+1):
        if dp[k] < 10**10:

            if k < C1:
                # Coupon1 を使う
                dp1[k+1] = min(dp1[k+1], dp[k] + max(P[i]-Coupons1[k], 0))

            if 0 <= i-k < C2:
                dp1[k] = min(dp1[k], dp[k] + P[i] * (100-Coupons2[i-k])//100)

    dp = dp1

if C < N:
    ans = min(dp) + sum(P[C:])
else:
    ans = min(dp)
print(ans)
0