結果
| 問題 |
No.1015 おつりは要らないです
|
| コンテスト | |
| ユーザー |
imoni_kawaii
|
| 提出日時 | 2020-06-12 10:41:36 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,069 bytes |
| コンパイル時間 | 2,305 ms |
| コンパイル使用メモリ | 195,440 KB |
| 最終ジャッジ日時 | 2025-01-11 01:42:15 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 28 WA * 5 |
ソースコード
#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];
}
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;
}
imoni_kawaii