結果

問題 No.1430 Coup de Coupon
ユーザー 小野寺健小野寺健
提出日時 2021-05-20 09:07:11
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 778 bytes
コンパイル時間 92 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 215,712 KB
最終ジャッジ日時 2024-04-18 13:58:54
合計ジャッジ時間 3,991 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 28 ms
16,256 KB
testcase_01 AC 30 ms
10,880 KB
testcase_02 AC 29 ms
10,880 KB
testcase_03 AC 62 ms
11,904 KB
testcase_04 AC 56 ms
11,136 KB
testcase_05 AC 41 ms
10,880 KB
testcase_06 TLE -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

N, C = map(int, input().split())

P = []
for _ in range(N):
    P.append(int(input()))
    
P.sort(reverse=True)

TY = []
TP = []
for _ in range(C):
    T, X = map(int, input().split())
    if T == 1:
        TY.append(X)
    else:
        TP.append(X)
TY.sort(reverse=True)
TP.sort(reverse=True)
L = len(TY)

DP = [[float('inf')] * (L+1) for _ in range(N+1)]
DP[0][0] = 0

for i in range(N):
    for j in range(L+1):
        if i-j < 0:
            cost = 0
        elif i-j < len(TP):
            cost = P[i] * (100 - TP[i-j]) // 100
        else:
            cost = P[i]
        DP[i+1][j] = min(DP[i+1][j], DP[i][j] + cost)
        if j < L:
            cost = P[i] - min(P[i], TY[j])
            DP[i+1][j+1] = min(DP[i+1][j+1], DP[i][j] + cost)

print(min(DP[N]))
        
0