結果

問題 No.1430 Coup de Coupon
ユーザー tko919tko919
提出日時 2021-03-14 15:17:55
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 208 ms / 2,000 ms
コード長 1,114 bytes
コンパイル時間 2,318 ms
コンパイル使用メモリ 201,592 KB
実行使用メモリ 199,544 KB
最終ジャッジ日時 2024-04-23 22:55:09
合計ジャッジ時間 6,236 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,248 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 208 ms
199,424 KB
testcase_04 AC 4 ms
5,376 KB
testcase_05 AC 4 ms
5,376 KB
testcase_06 AC 186 ms
199,296 KB
testcase_07 AC 191 ms
199,408 KB
testcase_08 AC 185 ms
199,424 KB
testcase_09 AC 187 ms
199,296 KB
testcase_10 AC 185 ms
199,436 KB
testcase_11 AC 187 ms
199,340 KB
testcase_12 AC 187 ms
199,328 KB
testcase_13 AC 188 ms
199,544 KB
testcase_14 AC 188 ms
199,296 KB
testcase_15 AC 189 ms
199,376 KB
testcase_16 AC 188 ms
199,368 KB
testcase_17 AC 195 ms
199,296 KB
testcase_18 AC 186 ms
199,296 KB
testcase_19 AC 188 ms
199,424 KB
testcase_20 AC 56 ms
63,872 KB
testcase_21 AC 40 ms
43,776 KB
testcase_22 AC 2 ms
5,376 KB
testcase_23 AC 2 ms
5,376 KB
testcase_24 AC 3 ms
5,376 KB
testcase_25 AC 20 ms
24,704 KB
testcase_26 AC 13 ms
15,360 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

//template
#define rep(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define ALL(v) (v).begin(),(v).end()
using ll=long long int;
const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12;
template<typename T>inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T>inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
//end

ll dp[5010][5010];

int main(){
   int n,m;
   cin>>n>>m;
   vector<int> p(n);
   rep(i,0,n)cin>>p[i];
   sort(ALL(p),greater<int>());

   vector<int> cs[2];
   rep(i,0,m){
      int t,x;
      cin>>t>>x; t--;
      cs[t].push_back(x);
   }
   rep(i,0,2){
      sort(ALL(cs[i]),greater<int>());
      cs[i].resize(n+1);
   }

   rep(i,0,n+1)rep(j,0,n+1)dp[i][j]=INF;
   dp[0][0]=0;
   rep(i,0,n)rep(j,0,n)if(dp[i][j]!=INF){
      if(i+j==n)continue;
      chmin(dp[i+1][j],dp[i][j]+max(0,p[i+j]-cs[0][i]));
      chmin(dp[i][j+1],dp[i][j]+p[i+j]/100*(100-cs[1][j]));
   }
   ll res=INF;
   rep(i,0,n+1)chmin(res,dp[i][n-i]);
   cout<<res<<'\n';
   return 0;
}
0