結果
問題 |
No.1015 おつりは要らないです
|
ユーザー |
|
提出日時 | 2020-04-03 22:38:24 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 11,924 bytes |
コンパイル時間 | 1,430 ms |
コンパイル使用メモリ | 115,648 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-03 04:53:51 |
合計ジャッジ時間 | 3,111 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 12 WA * 21 |
ソースコード
#include <iostream> #include <vector> #include <algorithm> #include <cmath> #include <queue> #include <string> #include <map> #include <set> #include <stack> #include <tuple> #include <deque> #include <numeric> #include <bitset> #include <iomanip> #include <cassert> #include <chrono> #include <random> #include <limits> #include <iterator> #include <functional> #include <sstream> #include <complex> using namespace std; typedef long long ll; typedef uint64_t ull; typedef pair<int, int> P; typedef pair<int, double> Pid; typedef pair<double, int> Pdi; typedef pair<ll, int> Pl; typedef pair<ll, ll> Pll; typedef pair<int, pair<int, int>> PP; typedef pair<P, int> PPi; constexpr double PI = 3.1415926535897932; // acos(-1) constexpr double EPS = 1e-9; constexpr int INF = 1001001001; constexpr int mod = 1000000007; // constexpr int mod = 998244353; #define chmax(x, y) x = max(x, y) #define chmin(x, y) x = min(x, y) #define chadd(x, y) x = (x + y) % mod int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); int n; int x, y, z; cin >> n >> x >> y >> z; vector<int> a(n); for(int i = 0; i < n; ++i) cin >> a[i]; sort(a.begin(), a.end(), greater<int>()); for(int i = 0; i < n; ++i){ int need = a[i] / 10000; if(need <= z){ a[i] -= need * 10000; z -= need; need = a[i] / 5000; if(need <= y){ a[i] -= need * 5000; y -= need; need = a[i] / 1000; if(need <= x){ a[i] -= need * 1000; x -= need; if(a[i] == 0){ if(x > 0){ --x; continue; } if(y > 0){ --y; continue; } if(z > 0){ --z; continue; } } else{ need = ceil((double)a[i] / 1000); if(need <= x){ x -= need; continue; } need = ceil((double)a[i] / 5000); if(need <= y){ y -= need; continue; } need = ceil((double)a[i] / 10000); if(need <= z){ z -= need; continue; } } } else{ a[i] -= x * 1000; x = 0; if(a[i] == 0){ if(x > 0){ --x; continue; } if(y > 0){ --y; continue; } if(z > 0){ --z; continue; } } else{ need = ceil((double)a[i] / 1000); if(need <= x){ x -= need; continue; } need = ceil((double)a[i] / 5000); if(need <= y){ y -= need; continue; } need = ceil((double)a[i] / 10000); if(need <= z){ z -= need; continue; } } } } else{ a[i] -= y * 5000; y = 0; need = a[i] / 1000; if(need <= x){ a[i] -= need * 1000; x -= need; if(a[i] == 0){ if(x > 0){ --x; continue; } if(y > 0){ --y; continue; } if(z > 0){ --z; continue; } } else{ need = ceil((double)a[i] / 1000); if(need <= x){ x -= need; continue; } need = ceil((double)a[i] / 5000); if(need <= y){ y -= need; continue; } need = ceil((double)a[i] / 10000); if(need <= z){ z -= need; continue; } } } else{ a[i] -= x * 1000; x -= need; if(a[i] == 0){ if(x > 0){ --x; continue; } if(y > 0){ --y; continue; } if(z > 0){ --z; continue; } } else{ need = ceil((double)a[i] / 1000); if(need <= x){ x -= need; continue; } need = ceil((double)a[i] / 5000); if(need <= y){ y -= need; continue; } need = ceil((double)a[i] / 10000); if(need <= z){ z -= need; continue; } } } } } else{ a[i] -= z * 10000; z = 0; need = a[i] / 5000; if(need <= y){ a[i] -= need * 5000; y -= need; need = a[i] / 1000; if(need <= x){ a[i] -= need * 1000; x -= need; if(a[i] == 0){ if(x > 0){ --x; continue; } if(y > 0){ --y; continue; } if(z > 0){ --z; continue; } } else{ need = ceil((double)a[i] / 1000); if(need <= x){ x -= need; continue; } need = ceil((double)a[i] / 5000); if(need <= y){ y -= need; continue; } need = ceil((double)a[i] / 10000); if(need <= z){ z -= need; continue; } } } else{ a[i] -= x * 1000; x = 0; if(a[i] == 0){ if(x > 0){ --x; continue; } if(y > 0){ --y; continue; } if(z > 0){ --z; continue; } } else{ need = ceil((double)a[i] / 1000); if(need <= x){ x -= need; continue; } need = ceil((double)a[i] / 5000); if(need <= y){ y -= need; continue; } need = ceil((double)a[i] / 10000); if(need <= z){ z -= need; continue; } } } } else{ a[i] -= y * 5000; y -= need; need = a[i] / 1000; if(need <= x){ a[i] -= need * 1000; x -= need; if(a[i] == 0){ if(x > 0){ --x; continue; } if(y > 0){ --y; continue; } if(z > 0){ --z; continue; } } else{ need = ceil((double)a[i] / 1000); if(need <= x){ x -= need; continue; } need = ceil((double)a[i] / 5000); if(need <= y){ y -= need; continue; } need = ceil((double)a[i] / 10000); if(need <= z){ z -= need; continue; } } } else{ a[i] -= x * 1000; x = 0; if(a[i] == 0){ if(x > 0){ --x; continue; } if(y > 0){ --y; continue; } if(z > 0){ --z; continue; } } else{ need = ceil((double)a[i] / 1000); if(need <= x){ x -= need; continue; } need = ceil((double)a[i] / 5000); if(need <= y){ y -= need; continue; } need = ceil((double)a[i] / 10000); if(need <= z){ z -= need; continue; } } } } } cout << "No\n"; return 0; } cout << "Yes\n"; }