結果

問題 No.1430 Coup de Coupon
ユーザー tcltktcltk
提出日時 2021-06-26 06:55:41
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,692 ms / 2,000 ms
コード長 1,244 bytes
コンパイル時間 418 ms
コンパイル使用メモリ 87,080 KB
実行使用メモリ 299,240 KB
最終ジャッジ日時 2023-09-07 13:45:22
合計ジャッジ時間 21,461 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 201 ms
81,028 KB
testcase_01 AC 208 ms
80,772 KB
testcase_02 AC 202 ms
80,888 KB
testcase_03 AC 213 ms
84,520 KB
testcase_04 AC 217 ms
84,172 KB
testcase_05 AC 211 ms
84,072 KB
testcase_06 AC 1,388 ms
280,956 KB
testcase_07 AC 1,604 ms
280,464 KB
testcase_08 AC 220 ms
84,264 KB
testcase_09 AC 473 ms
141,980 KB
testcase_10 AC 638 ms
183,900 KB
testcase_11 AC 817 ms
222,280 KB
testcase_12 AC 994 ms
254,204 KB
testcase_13 AC 1,221 ms
281,152 KB
testcase_14 AC 1,382 ms
293,248 KB
testcase_15 AC 1,493 ms
299,240 KB
testcase_16 AC 1,591 ms
298,524 KB
testcase_17 AC 1,692 ms
293,176 KB
testcase_18 AC 1,258 ms
281,852 KB
testcase_19 AC 1,318 ms
281,948 KB
testcase_20 AC 778 ms
186,728 KB
testcase_21 AC 260 ms
89,800 KB
testcase_22 AC 200 ms
80,828 KB
testcase_23 AC 227 ms
83,932 KB
testcase_24 AC 221 ms
84,380 KB
testcase_25 AC 228 ms
84,712 KB
testcase_26 AC 299 ms
91,740 KB
権限があれば一括ダウンロードができます

ソースコード

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**20] * (C1+1) for _ in range(N+1)]
dp[0][0] = 0
for i in range(N):
    for k in range(C1+1):

        if C <= i:
            dp[i+1][k] = dp[i][k] + P[i]
        
        else:
            # Coupon1: k枚使った
            # Coupon2: min(i-k, C2) 枚使った

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

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

ans = min(dp[N])
print(ans)
0