結果

問題 No.1430 Coup de Coupon
ユーザー firiexpfiriexp
提出日時 2021-03-14 14:23:17
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 48 ms / 2,000 ms
コード長 1,787 bytes
コンパイル時間 1,074 ms
コンパイル使用メモリ 109,884 KB
実行使用メモリ 27,744 KB
最終ジャッジ日時 2023-08-06 01:19:10
合計ジャッジ時間 2,795 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 4 ms
4,376 KB
testcase_05 AC 3 ms
4,376 KB
testcase_06 AC 5 ms
4,504 KB
testcase_07 AC 5 ms
4,380 KB
testcase_08 AC 4 ms
4,376 KB
testcase_09 AC 20 ms
12,336 KB
testcase_10 AC 31 ms
18,912 KB
testcase_11 AC 39 ms
23,196 KB
testcase_12 AC 44 ms
26,624 KB
testcase_13 AC 46 ms
27,688 KB
testcase_14 AC 44 ms
26,716 KB
testcase_15 AC 40 ms
23,460 KB
testcase_16 AC 33 ms
19,496 KB
testcase_17 AC 21 ms
12,656 KB
testcase_18 AC 47 ms
27,648 KB
testcase_19 AC 48 ms
27,744 KB
testcase_20 AC 38 ms
27,588 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 2 ms
4,376 KB
testcase_23 AC 2 ms
4,376 KB
testcase_24 AC 2 ms
4,376 KB
testcase_25 AC 1 ms
4,380 KB
testcase_26 AC 3 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;

template <class T, class U>
vector<T> make_v(U size, const T& init){ return vector<T>(static_cast<size_t>(size), init); }

template<class... Ts, class U>
auto make_v(U size, Ts... rest) { return vector<decltype(make_v(rest...))>(static_cast<size_t>(size), make_v(rest...)); }

template<class T> void chmin(T &a, const T &b){ a = (a < b ? a : b); }
template<class T> void chmax(T &a, const T &b){ a = (a > b ? a : b); }

int main() {
    int n, c;
    cin >> n >> c;
    vector<int> p(n);
    for (auto &&i : p) scanf("%d", &i);
    sort(p.begin(),p.end(), greater<>());
    vector<int> T1, T2;
    for (int i = 0; i < c; ++i) {
        int t, x;
        cin >> t >> x;
        if(t == 1) T1.emplace_back(x);
        else T2.emplace_back(x);
    }
    sort(T1.begin(),T1.end(), greater<>());
    sort(T2.begin(),T2.end(), greater<>());
    auto dp = make_v(T1.size()+1, T2.size()+1, INF<int>);
    dp[0][0] = 0;
    int ans = INF<int>;
    for (int i = 0; i <= T1.size(); ++i) {
        for (int j = 0; j <= T2.size(); ++j) {
            if(i+j > n) continue;
            if(i) chmin(dp[i][j], dp[i-1][j]+max(p[i+j-1]-T1[i-1], 0));
            if(j) chmin(dp[i][j], dp[i][j-1]+p[i+j-1]/100*(100-T2[j-1]));
            if(i+j == n) chmin(ans, dp[i][j]);
        }
    }
    int val = 0;
    for (int i = c; i < n; ++i) {
        val += p[i];
    }
    cout << min(ans, dp.back().back()+val) << "\n";
    return 0;
}
0