結果

問題 No.1430 Coup de Coupon
ユーザー merom686merom686
提出日時 2021-03-14 14:49:51
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 28 ms / 2,000 ms
コード長 1,267 bytes
コンパイル時間 1,130 ms
コンパイル使用メモリ 91,880 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-06 01:55:59
合計ジャッジ時間 2,459 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

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

int dp[5001];

int main() {
    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());
    reverse(p.begin(), p.end());

    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());
        reverse(q[i].begin(), q[i].end());
        while ((int)q[i].size() < n) q[i].push_back(0);
    }

    constexpr int INF = 1 << 29;

    for (int j = 0; j <= n; j++) {
        dp[j] = INF;
    }
    dp[0] = 0;

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

    int r = INF;
    for (int j = 0; j <= n; j++) {
        r = min(r, dp[j]);
    }
    cout << r << endl;

    return 0;
}
0