結果
| 問題 |
No.1430 Coup de Coupon
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-03-21 14:28:34 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 193 ms / 2,000 ms |
| コード長 | 1,414 bytes |
| コンパイル時間 | 4,193 ms |
| コンパイル使用メモリ | 236,120 KB |
| 実行使用メモリ | 199,040 KB |
| 最終ジャッジ日時 | 2024-11-22 07:09:38 |
| 合計ジャッジ時間 | 8,547 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 27 |
ソースコード
#include <bits/stdc++.h>
#define pt(sth) cout << sth << "\n"
#define itr(x,c) for(auto x=c.begin();x!=c.end();x++)
#define ritr(x,c) for(auto x=c.rbegin();x!=c.rend();x++)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define __builtin_popcount(v) popcount(v)
using namespace std;
#include <atcoder/all>
using namespace atcoder;
typedef long long ll;
typedef pair<ll, ll> pll;
template<class T>bool chmax(T &a, const T &b) {if(a<b) {a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) {if(b<a) {a=b; return 1;} return 0;}
static const ll INF=1e18;
static const ll MAX=101010;
static const ll MOD=1e9+7;
//static const ll MOD=998244353;
//for(i=0;i<N;i++) cin>>a[i];
typedef vector<ll> v1d;
typedef vector<v1d> v2d;
typedef vector<v2d> v3d;
typedef vector<v3d> v4d;
int main(void) {
ll i,j,k,l;
ll N,C;cin>>N>>C;
v1d p(N),a,b;
for(i=0;i<N;i++) cin>>p[i];
for(i=0;i<C;i++){
ll t,x;cin>>t>>x;
if(t==1) a.push_back(x);
else b.push_back(x);
}
while(ll(a.size())<N) a.push_back(0);
while(ll(b.size())<N) b.push_back(0);
sort(rall(p));sort(rall(a));sort(rall(b));
v2d dp(N+1,v1d(N+1,INF));
dp[0][0]=0;
for(i=0;i<N;i++){
for(j=0;j<=i;j++){
chmin(dp[i+1][j+1],dp[i][j]+max(p[i]-a[j],0LL));
chmin(dp[i+1][j],dp[i][j]+p[i]*(100-b[i-j])/100);
}
}
pt(*min_element(all(dp[N])));
}