結果

問題 No.1430 Coup de Coupon
ユーザー chocoruskchocorusk
提出日時 2021-03-14 18:39:44
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,589 bytes
コンパイル時間 3,816 ms
コンパイル使用メモリ 188,616 KB
実行使用メモリ 102,840 KB
最終ジャッジ日時 2024-04-24 01:26:30
合計ジャッジ時間 5,303 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#include <list>
#include <atcoder/all>
#define popcount __builtin_popcount
using namespace std;
using namespace atcoder;
typedef long long ll;
typedef pair<int, int> P;
int dp[5050][5050];
int main()
{
    int n, c; cin>>n>>c;
    int p[5050];
    for(int i=0; i<n; i++){
        cin>>p[i];
    }
    vector<int> v1, v2;
    for(int i=0; i<c; i++){
        int t, x; cin>>t>>x;
        if(t==1) v1.push_back(x);
        else v2.push_back(x);
    }
    sort(v1.begin(), v1.end(), greater<int>());
    sort(v2.begin(), v2.end(), greater<int>());
    const int INF=1e9+7;
    for(int i=0; i<=n; i++){
        for(int j=0; j<=v1.size(); j++){
            dp[i][j]=INF;
        }
    }
    dp[0][0]=0;
    for(int i=0; i<n; i++){
        for(int j=0; j<=v1.size() && j<=i; j++){
            int p1=p[i];
            if(i-j<v2.size()) p1=p[i]*(100-v2[i-j])/100;
            dp[i+1][j]=min(dp[i+1][j], dp[i][j]+p1);
            if(j<v1.size()){
                dp[i+1][j+1]=min(dp[i+1][j+1], dp[i][j]+max(p[i]-v1[j], 0));
            }
        }
    }
    int ans=INF;
    for(int i=0; i<=v1.size(); i++) ans=min(ans, dp[n][i]);
    cout<<ans<<endl;
    return 0;
}
0