結果

問題 No.1430 Coup de Coupon
ユーザー umezoumezo
提出日時 2021-03-14 17:11:35
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 112 ms / 2,000 ms
コード長 954 bytes
コンパイル時間 2,347 ms
コンパイル使用メモリ 201,260 KB
実行使用メモリ 101,776 KB
最終ジャッジ日時 2024-04-24 00:22:58
合計ジャッジ時間 5,530 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 53 ms
101,504 KB
testcase_01 AC 53 ms
101,632 KB
testcase_02 AC 52 ms
101,632 KB
testcase_03 AC 53 ms
101,504 KB
testcase_04 AC 55 ms
101,680 KB
testcase_05 AC 55 ms
101,632 KB
testcase_06 AC 101 ms
101,760 KB
testcase_07 AC 102 ms
101,776 KB
testcase_08 AC 100 ms
101,760 KB
testcase_09 AC 105 ms
101,688 KB
testcase_10 AC 108 ms
101,504 KB
testcase_11 AC 109 ms
101,504 KB
testcase_12 AC 111 ms
101,632 KB
testcase_13 AC 111 ms
101,540 KB
testcase_14 AC 112 ms
101,632 KB
testcase_15 AC 110 ms
101,632 KB
testcase_16 AC 110 ms
101,504 KB
testcase_17 AC 108 ms
101,564 KB
testcase_18 AC 111 ms
101,632 KB
testcase_19 AC 111 ms
101,564 KB
testcase_20 AC 81 ms
101,588 KB
testcase_21 AC 54 ms
101,504 KB
testcase_22 AC 54 ms
101,504 KB
testcase_23 AC 52 ms
101,584 KB
testcase_24 AC 52 ms
101,504 KB
testcase_25 AC 54 ms
101,572 KB
testcase_26 AC 56 ms
101,724 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;

#include <bits/stdc++.h>
using namespace std;

int dp[5010][5010];
const int INF=1e9+7;

int main(){
  int n,c;
  cin>>n>>c;
  vector<int> P(n);
  rep(i,n) cin>>P[i];
  sort(ALL(P));
  reverse(ALL(P));
  vector<int> X1,X2;
  rep(i,c){
    int t,x;
    cin>>t>>x;
    if(t==1) X1.push_back(x);
    else X2.push_back(x);
  }
  sort(ALL(X1));
  sort(ALL(X2));
  reverse(ALL(X1));
  reverse(ALL(X2));
  int n1=X1.size();
  
  rep(i,5010){
    rep(j,5010) dp[i][j]=INF;
  }
  dp[0][0]=0;
  
  for(int i=0;i<=min(n,c)-1;i++){
    for(int j=0;j<=c;j++){
      if(j<n1) dp[i+1][j+1]=min(dp[i+1][j+1],dp[i][j]+max(0,P[i]-X1[j]));
      if(i-j>=0 && i-j<c-n1) dp[i+1][j]=min(dp[i+1][j],dp[i][j]+P[i]/100*(100-X2[i-j]));
    }
  }
  int ans=INF;
  rep(j,n1+1) ans=min(ans,dp[min(c,n)][j]);
  for(int i=min(n,c);i<n;i++) ans+=P[i];
  cout<<ans<<endl;

  return 0;
}
0