結果

問題 No.1430 Coup de Coupon
コンテスト
ユーザー firiexp
提出日時 2021-03-14 14:23:17
言語 C++17
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 31 ms / 2,000 ms
コード長 1,787 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 889 ms
コンパイル使用メモリ 124,572 KB
実行使用メモリ 28,160 KB
最終ジャッジ日時 2026-06-18 18:47:17
合計ジャッジ時間 2,536 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge2_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 27
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#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