結果
問題 | No.1015 おつりは要らないです |
ユーザー |
![]() |
提出日時 | 2020-04-19 18:52:26 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 39 ms / 2,000 ms |
コード長 | 2,041 bytes |
コンパイル時間 | 1,682 ms |
コンパイル使用メモリ | 175,232 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-11-18 07:18:54 |
合計ジャッジ時間 | 3,575 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 33 |
ソースコード
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<int> vi; typedef vector<ll> vl; typedef pair<int,int> pii; typedef int _loop_int; #define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i) #define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i) #define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i) #define DEBUG(x) cout<<#x<<": "<<x<<endl #define DEBUG2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl #define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl #define DEBUG_ARR(v,n) cout<<#v<<":";REP(i,n)cout<<" "<<v[i];cout<<endl #define ALL(a) (a).begin(),(a).end() const ll MOD = 1000000007ll; #define FIX(a) ((a)%MOD+MOD)%MOD int main() { ios::sync_with_stdio(false); cin.tie(0); int n,x,y,z; cin>>n>>x>>y>>z; //vi a(n); priority_queue<int> p; int use=0; REP(i,n) { int tmp; cin>>tmp; if(z>0){ use = min(z,tmp/10000); tmp -= use*10000; z -= use; } p.push(tmp); } while(z>0 && !p.empty()){ auto q = p.top(); p.pop(); //ここでzが余っているということはp内の金額はすべて0円以上10000円未満 z--; } while(y>0 && !p.empty()){ auto q = p.top(); p.pop(); if(q < 5000) { p.push(q); break; } use = min(y,q/5000); q -= use*5000; p.push(q); y -= use; } while(y>0 && !p.empty()){ auto q = p.top(); p.pop(); y--; } while(x>0 && !p.empty()){ auto q = p.top(); p.pop(); if(q < 1000){ p.push(q); break; } use = min(x,q/1000); q -= use*1000; p.push(q); x -= use; } while(x>0 && !p.empty()){ auto q = p.top(); p.pop(); x--; } if(p.empty()) cout << "Yes" << endl; else cout << "No" << endl; return 0; }