結果

問題 No.1430 Coup de Coupon
ユーザー monnumonnu
提出日時 2021-03-14 14:20:46
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 85 ms / 2,000 ms
コード長 1,319 bytes
コンパイル時間 1,621 ms
コンパイル使用メモリ 172,668 KB
実行使用メモリ 27,904 KB
最終ジャッジ日時 2024-04-23 21:50:29
合計ジャッジ時間 3,151 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,248 KB
testcase_02 AC 2 ms
5,248 KB
testcase_03 AC 3 ms
5,376 KB
testcase_04 AC 4 ms
5,376 KB
testcase_05 AC 4 ms
5,376 KB
testcase_06 AC 21 ms
5,376 KB
testcase_07 AC 22 ms
5,376 KB
testcase_08 AC 18 ms
5,376 KB
testcase_09 AC 34 ms
12,544 KB
testcase_10 AC 46 ms
18,688 KB
testcase_11 AC 65 ms
23,552 KB
testcase_12 AC 77 ms
26,752 KB
testcase_13 AC 82 ms
27,776 KB
testcase_14 AC 81 ms
26,752 KB
testcase_15 AC 63 ms
23,680 KB
testcase_16 AC 50 ms
19,456 KB
testcase_17 AC 36 ms
12,928 KB
testcase_18 AC 83 ms
27,776 KB
testcase_19 AC 85 ms
27,776 KB
testcase_20 AC 50 ms
27,904 KB
testcase_21 AC 3 ms
5,376 KB
testcase_22 AC 2 ms
5,376 KB
testcase_23 AC 1 ms
5,376 KB
testcase_24 AC 2 ms
5,376 KB
testcase_25 AC 2 ms
5,376 KB
testcase_26 AC 4 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
//#include <atcoder/all>
//using namespace atcoder;
using ll=long long;
using Graph=vector<vector<int>>;
#define MAX 200003
#define MOD 1000000007
#define INF 2000000000

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> X1,X2;
  for(int i=0;i<C;i++){
    int T,X;
    cin>>T>>X;
    if(T==1){
      X1.push_back(X);
    }else{
      X2.push_back(X);
    }
  }
  sort(X1.begin(),X1.end());
  reverse(X1.begin(),X1.end());
  sort(X2.begin(),X2.end());
  reverse(X2.begin(),X2.end());
  int n=X1.size();
  int m=X2.size();
  vector<vector<int>> dp(n+1,vector<int>(m+1,INF));
  dp[0][0]=0;
  for(int i=0;i<min(N,C);i++){
    int num=i+1;
    for(int j=0;j<=num;j++){
      int a=j;
      int b=num-j;
      if(a>n||b>m){
        continue;
      }
      if(a>0){
        dp[a][b]=min(dp[a][b],dp[a-1][b]+max(P[i]-X1[a-1],0));
      }
      if(b>0){
        dp[a][b]=min(dp[a][b],dp[a][b-1]+P[i]*(100-X2[b-1])/100);
      }
    }
  }
  int ans=INF;
  for(int j=0;j<=min(N,C);j++){
    int a=j;
    int b=min(N,C)-j;
    if(a>n||b>m){
      continue;
    }
    ans=min(ans,dp[a][b]);
  }
  for(int i=min(N,C);i<N;i++){
    ans+=P[i];
  }
  cout<<ans<<endl;
}
0