結果

問題 No.1430 Coup de Coupon
ユーザー tko919tko919
提出日時 2021-03-14 14:10:56
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 984 bytes
コンパイル時間 2,443 ms
コンパイル使用メモリ 201,612 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-23 21:31:00
合計ジャッジ時間 4,959 ms
ジャッジサーバーID
(参考情報)
judge4 / 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 3 ms
5,376 KB
testcase_04 AC 4 ms
5,376 KB
testcase_05 AC 3 ms
5,376 KB
testcase_06 AC 69 ms
5,376 KB
testcase_07 AC 108 ms
5,376 KB
testcase_08 AC 97 ms
5,376 KB
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 AC 76 ms
5,376 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 2 ms
5,376 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:29:20: warning: 'id' may be used uninitialized [-Wmaybe-uninitialized]
   29 |       int add=p[i],id;
      |                    ^~

ソースコード

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



int main(){
   int n,c;
   cin>>n>>c;
   vector<int> p(n);
   rep(i,0,n)cin>>p[i];
   using P=array<int,2>;
   vector<P> cs(c);
   rep(i,0,c)cin>>cs[i][0]>>cs[i][1];

   sort(ALL(p),greater<int>());
   bitset<5010> used;
   ll res=0;
   rep(i,0,n){
      int add=p[i],id;
      rep(j,0,c)if(!used[j]){
         int sub;
         if(cs[j][0]==1)sub=max(0,p[i]-cs[j][1]);
         else sub=p[i]/100*(100-cs[j][1]);
         if(chmin(add,sub))id=j;
      }
      used[id]=1;
      res+=add;
   }
   cout<<res<<'\n';
   return 0;
}
0