結果
問題 | No.1015 おつりは要らないです |
ユーザー |
![]() |
提出日時 | 2020-06-12 10:43:10 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 22 ms / 2,000 ms |
コード長 | 1,079 bytes |
コンパイル時間 | 1,913 ms |
コンパイル使用メモリ | 195,452 KB |
最終ジャッジ日時 | 2025-01-11 01:42:26 |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 33 |
ソースコード
#include <bits/stdc++.h> #define REP(i, m, n) for(int i = (int)(m); i < (int)(n); ++i) #define rep(i, n) REP(i, 0, n) using namespace std; using ll = long long; using ld = long double; using pll = pair<ll, ll>; template<class T, class U> inline bool chmax(T &a, const U &b) { if(a < b) { a = b; return true; } return false; } template<class T, class U> inline bool chmin(T &a, const U &b) { if(a > b) { a = b; return true; } return false; } ll n, x[3], a[100000]; ll P[3] = {1000, 5000, 10000}; int main() { cin.tie(0); ios::sync_with_stdio(false); cin >> n; rep(i, 3) cin >> x[i]; rep(i, n) cin >> a[i], a[i]++; for(int k = 2; k >= 0; k--) { rep(i, n) if(a[i] >= P[k]) { if(x[k] <= 0) break; x[k] -= a[i]/P[k]; a[i] %= P[k]; if(x[k] < 0) a[i] += abs(x[k])*P[k], x[k] = 0; } if(x[k] > 0) { sort(a, a+n, greater<ll>()); rep(i, n) { if(x[k] <= 0) break; x[k]--; a[i] = 0; } } } bool ok = true; rep(i, n) if(a[i] > 0) ok = false; cout << (ok ? "Yes" : "No") << '\n'; return 0; }