結果

問題 No.1430 Coup de Coupon
ユーザー merom686merom686
提出日時 2021-03-14 15:06:57
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 38 ms / 2,000 ms
コード長 1,164 bytes
コンパイル時間 1,465 ms
コンパイル使用メモリ 112,824 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-23 22:46:35
合計ジャッジ時間 2,768 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 36 ms
5,376 KB
testcase_04 AC 3 ms
5,376 KB
testcase_05 AC 3 ms
5,376 KB
testcase_06 AC 37 ms
5,376 KB
testcase_07 AC 37 ms
5,376 KB
testcase_08 AC 37 ms
5,376 KB
testcase_09 AC 37 ms
5,376 KB
testcase_10 AC 37 ms
5,376 KB
testcase_11 AC 37 ms
5,376 KB
testcase_12 AC 37 ms
5,376 KB
testcase_13 AC 37 ms
5,376 KB
testcase_14 AC 37 ms
5,376 KB
testcase_15 AC 38 ms
5,376 KB
testcase_16 AC 37 ms
5,376 KB
testcase_17 AC 37 ms
5,376 KB
testcase_18 AC 37 ms
5,376 KB
testcase_19 AC 37 ms
5,376 KB
testcase_20 AC 12 ms
5,376 KB
testcase_21 AC 8 ms
5,376 KB
testcase_22 AC 2 ms
5,376 KB
testcase_23 AC 2 ms
5,376 KB
testcase_24 AC 2 ms
5,376 KB
testcase_25 AC 5 ms
5,376 KB
testcase_26 AC 4 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n, c;
    cin >> n >> c;

    vector<int> p(n);
    for (int i = 0; i < n; i++) {
        cin >> p[i];
    }
    sort(p.begin(), p.end(), greater<>());

    vector<int> q[2];
    for (int i = 0; i < c; i++) {
        int t, x;
        cin >> t >> x;

        q[t - 1].push_back(x);
    }
    for (int i = 0; i < 2; i++) {
        sort(q[i].begin(), q[i].end(), greater<>());
        q[i].resize(n, 0);
    }

    constexpr int INF = 1 << 29;

    vector<int> dp(n + 1, INF);
    dp[0] = 0;

    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j >= 0; j--) {
            int j0 = j - 1;
            int j1 = i - j;
            int t0 = j0 >= 0 ? dp[j - 1] + max(p[i] - q[0][j0], 0) : INF;
            int t1 = j1 >= 0 ? dp[j] + p[i] / 100 * (100 - q[1][j1]) : INF;
            dp[j] = min(t0, t1);
        }
    }

    cout << *min_element(dp.begin(), dp.end()) << endl;

    return 0;
}
0