結果

問題 No.1430 Coup de Coupon
ユーザー t98slidert98slider
提出日時 2023-03-30 22:52:02
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 184 ms / 2,000 ms
コード長 975 bytes
コンパイル時間 2,046 ms
コンパイル使用メモリ 179,148 KB
実行使用メモリ 198,872 KB
最終ジャッジ日時 2023-10-22 06:25:56
合計ジャッジ時間 6,057 ms
ジャッジサーバーID
(参考情報)
judge9 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 182 ms
198,872 KB
testcase_04 AC 3 ms
4,348 KB
testcase_05 AC 3 ms
4,348 KB
testcase_06 AC 182 ms
198,872 KB
testcase_07 AC 182 ms
198,872 KB
testcase_08 AC 181 ms
198,872 KB
testcase_09 AC 184 ms
198,872 KB
testcase_10 AC 184 ms
198,872 KB
testcase_11 AC 182 ms
198,872 KB
testcase_12 AC 181 ms
198,872 KB
testcase_13 AC 182 ms
198,872 KB
testcase_14 AC 182 ms
198,872 KB
testcase_15 AC 181 ms
198,872 KB
testcase_16 AC 182 ms
198,872 KB
testcase_17 AC 182 ms
198,872 KB
testcase_18 AC 181 ms
198,872 KB
testcase_19 AC 182 ms
198,872 KB
testcase_20 AC 51 ms
53,672 KB
testcase_21 AC 33 ms
35,456 KB
testcase_22 AC 2 ms
4,348 KB
testcase_23 AC 2 ms
4,348 KB
testcase_24 AC 2 ms
4,348 KB
testcase_25 AC 17 ms
19,088 KB
testcase_26 AC 10 ms
11,168 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, c, t, x;
    cin >> n >> c;
    vector<ll> p(n);
    vector<vector<ll>> tb(2);
    tb[0].reserve(n);
    tb[1].reserve(n);
    for(auto &&v : p) cin >> v;
    for(int i = 0; i < c; i++){
        cin >> t >> x;
        tb[t - 1].emplace_back(x);
    }
    for(int i = 0; i < 2; i++){
        while(tb[i].size() < n) tb[i].emplace_back(0);
        sort(tb[i].rbegin(), tb[i].rend());
    }
    sort(p.rbegin(), p.rend());
    vector<vector<ll>> dp(n + 1, vector<ll>(n + 1, 1ll << 60));
    dp[0][0] = 0;
    for(int i = 0; i < n; i++){
        for(int j = 0; j <= i; j++){
            dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + p[i] * (100 - tb[1][i - j]) / 100);
            dp[i + 1][j + 1] = min(dp[i + 1][j + 1], dp[i][j] + max(0ll, p[i] - tb[0][j]));
        }
    }
    cout << *min_element(dp[n].begin(), dp[n].end()) << '\n';
}
0