結果

問題 No.1430 Coup de Coupon
ユーザー ぷらぷら
提出日時 2021-03-14 14:19:32
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 102 ms / 2,000 ms
コード長 1,238 bytes
コンパイル時間 2,028 ms
コンパイル使用メモリ 172,868 KB
実行使用メモリ 101,504 KB
最終ジャッジ日時 2024-04-23 21:49:24
合計ジャッジ時間 4,053 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 15 ms
30,120 KB
testcase_04 AC 4 ms
5,376 KB
testcase_05 AC 3 ms
5,376 KB
testcase_06 AC 39 ms
101,504 KB
testcase_07 AC 40 ms
101,448 KB
testcase_08 AC 102 ms
101,392 KB
testcase_09 AC 100 ms
101,436 KB
testcase_10 AC 100 ms
101,392 KB
testcase_11 AC 96 ms
101,416 KB
testcase_12 AC 92 ms
101,344 KB
testcase_13 AC 84 ms
101,336 KB
testcase_14 AC 78 ms
101,252 KB
testcase_15 AC 69 ms
101,324 KB
testcase_16 AC 62 ms
101,472 KB
testcase_17 AC 52 ms
101,468 KB
testcase_18 AC 84 ms
101,304 KB
testcase_19 AC 83 ms
101,336 KB
testcase_20 AC 40 ms
53,172 KB
testcase_21 AC 10 ms
14,208 KB
testcase_22 AC 2 ms
5,376 KB
testcase_23 AC 1 ms
5,376 KB
testcase_24 AC 2 ms
5,376 KB
testcase_25 AC 6 ms
9,856 KB
testcase_26 AC 7 ms
11,520 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int dp[5005][5005];
 
int main() {
    int N,C;
    cin >> N >> C;
    vector<int>P(N);
    for(int i = 0; i < N; i++) {
        cin >> P[i];
    }
    vector<int>X,Y;
    for(int i = 0; i < C; i++) {
        int T,C;
        cin >> T >> C;
        if(T == 2) {
            X.push_back(C);
        }
        else {
            Y.push_back(C);
        }
    }
    sort(X.rbegin(),X.rend());
    sort(Y.rbegin(),Y.rend());
    sort(P.rbegin(),P.rend());
    for(int i = 0; i <= N; i++) {
        for(int j = 0; j <= C; j++) {
            dp[i][j] = 1e9;
        }
    }
    dp[0][0] = 0;
    for(int i = 0; i < N; i++) {
        for(int j = 0; j <= X.size(); j++) {
            if(dp[i][j] == 1e9) {
                continue;
            }
            if(j < X.size()) {
                dp[i+1][j+1] = min(dp[i+1][j+1],dp[i][j]+P[i]/100*(100-X[j]));
            }
            if(i >= j && i-j < Y.size()) {
                dp[i+1][j] = min(dp[i+1][j],dp[i][j]+max(0,P[i]-Y[i-j]));
            }
            dp[i+1][j] = min(dp[i+1][j],dp[i][j]+P[i]);
        }
    }
    int ans = 1e9;
    for(int i = 0; i <= X.size(); i++) {
        ans = min(ans,dp[N][i]);
    }
    cout << ans << endl;
}
0