結果

問題 No.1430 Coup de Coupon
ユーザー 👑 tamatotamato
提出日時 2021-03-14 14:44:27
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 641 ms / 2,000 ms
コード長 1,037 bytes
コンパイル時間 322 ms
コンパイル使用メモリ 82,560 KB
実行使用メモリ 273,028 KB
最終ジャッジ日時 2024-04-23 22:26:18
合計ジャッジ時間 7,789 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
53,152 KB
testcase_01 AC 34 ms
53,116 KB
testcase_02 AC 35 ms
53,920 KB
testcase_03 AC 49 ms
67,556 KB
testcase_04 AC 46 ms
64,256 KB
testcase_05 AC 41 ms
62,720 KB
testcase_06 AC 548 ms
272,488 KB
testcase_07 AC 550 ms
273,028 KB
testcase_08 AC 53 ms
68,860 KB
testcase_09 AC 155 ms
97,732 KB
testcase_10 AC 217 ms
106,884 KB
testcase_11 AC 291 ms
130,672 KB
testcase_12 AC 355 ms
152,884 KB
testcase_13 AC 441 ms
175,800 KB
testcase_14 AC 496 ms
195,504 KB
testcase_15 AC 554 ms
215,560 KB
testcase_16 AC 599 ms
233,084 KB
testcase_17 AC 641 ms
245,620 KB
testcase_18 AC 463 ms
174,652 KB
testcase_19 AC 470 ms
176,224 KB
testcase_20 AC 269 ms
127,884 KB
testcase_21 AC 77 ms
79,332 KB
testcase_22 AC 35 ms
52,864 KB
testcase_23 AC 42 ms
60,672 KB
testcase_24 AC 49 ms
64,896 KB
testcase_25 AC 62 ms
72,320 KB
testcase_26 AC 91 ms
82,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 1000000007
eps = 10**-9
inf = 10**18


def main():
    import sys
    input = sys.stdin.readline

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

    if len(C1) + len(C2) < N:
        for _ in range(N - M):
            C2.append(0)
        M = N

    dp = [[inf] * (len(C1) + 1) for _ in range(N+1)]
    dp[0][0] = 0
    for i in range(N):
        p = P[i]
        for j in range(len(C1) + 1):
            # use C1
            if j != len(C1):
                dp[i+1][j+1] = min(dp[i+1][j+1], dp[i][j] + max(0, p - C1[j]))
            # use C2
            if 0 <= i-j < len(C2):
                dp[i+1][j] = min(dp[i+1][j], dp[i][j] + p * (100 - C2[i - j]) // 100)
    print(min(dp[-1]))


if __name__ == '__main__':
    main()
0