結果
問題 | No.1015 おつりは要らないです |
ユーザー |
|
提出日時 | 2020-04-03 21:31:46 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 96 ms / 2,000 ms |
コード長 | 1,108 bytes |
コンパイル時間 | 1,497 ms |
コンパイル使用メモリ | 171,952 KB |
実行使用メモリ | 8,064 KB |
最終ジャッジ日時 | 2024-11-17 23:06:24 |
合計ジャッジ時間 | 4,571 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 33 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main() { cin.tie(nullptr); ios::sync_with_stdio(false); int n, x, y, z; cin >> n >> x >> y >> z; multiset<int> ms; for (int i = 0; i < n; i++) { int a; cin >> a; ms.emplace(a); } while (z && !ms.empty()) { auto w = *ms.rbegin(); ms.erase(ms.find(w)); if (w < 10000) { z--; continue; } int m = min(z, w / 10000); w -= m * 10000; z -= m; ms.emplace(w); } while (y && !ms.empty()) { auto w = *ms.rbegin(); ms.erase(ms.find(w)); if (w < 5000) { y--; continue; } int m = min(y, w / 5000); w -= m * 5000; y -= m; ms.emplace(w); } while (x && !ms.empty()) { auto w = *ms.rbegin(); ms.erase(ms.find(w)); if (w < 1000) { x--; continue; } int m = min(x, w / 1000); w -= m * 1000; x -= m; ms.emplace(w); } if (ms.empty()) cout << "Yes\n"; else cout << "No\n"; return 0; }