結果
| 問題 |
No.1015 おつりは要らないです
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-02-04 20:50:18 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 63 ms / 2,000 ms |
| コード長 | 772 bytes |
| コンパイル時間 | 1,764 ms |
| コンパイル使用メモリ | 199,736 KB |
| 最終ジャッジ日時 | 2025-01-18 11:16:32 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 33 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(int)(n); i++)
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int n;
cin >> n;
vector<pair<int, int> > money {{10000, 0}, {5000, 0}, {1000, 0}};
for (int i = 2; i >= 0; i--)
cin >> money[i].second;
priority_queue<int> q;
for (int i = 0; i < n; i++) {
int a;
cin >> a;
q.push(a);
}
for (auto &[k, v]: money) {
while (v > 0 && q.size()) {
int x = q.top();
if (k > x) {
--v;
q.pop();
} else {
int c = min(x / k, v);
v -= c;
x -= c * k;
q.pop();
q.push(x);
}
}
}
if (q.empty())
cout << "Yes" << endl;
else
cout << "No" << endl;
return 0;
}