結果
問題 |
No.1430 Coup de Coupon
|
ユーザー |
![]() |
提出日時 | 2021-03-14 14:10:56 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 984 bytes |
コンパイル時間 | 2,028 ms |
コンパイル使用メモリ | 200,168 KB |
最終ジャッジ日時 | 2025-01-19 16:33:48 |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 11 WA * 16 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:29:20: warning: ‘id’ may be used uninitialized [-Wmaybe-uninitialized] 29 | int add=p[i],id; | ^~
ソースコード
#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; }