結果
| 問題 | No.1015 おつりは要らないです |
| コンテスト | |
| ユーザー |
misora192
|
| 提出日時 | 2020-04-26 16:37:52 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 49 ms / 2,000 ms |
| コード長 | 740 bytes |
| コンパイル時間 | 1,610 ms |
| コンパイル使用メモリ | 173,748 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-11-18 07:19:22 |
| 合計ジャッジ時間 | 3,731 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 33 |
ソースコード
#include <bits/stdc++.h>
#define rep(i,n) for(int i=(0);i<(n);i++)
using namespace std;
typedef long long ll;
int main(){
cin.tie(0);
ios::sync_with_stdio(false);
ll n;
cin >> n;
ll cnt[3];
cin >> cnt[2] >> cnt[1] >> cnt[0];
ll f[3] = {10000ll, 5000ll, 1000ll};
priority_queue<ll> pq;
rep(i, n){
ll a;
cin >> a;
a++;
pq.push(a);
}
rep(i, 3){
while(cnt[i] > 0){
ll t = pq.top();
pq.pop();
if(t == 0){
cout << "Yes" << endl;
return 0;
}
if(t >= f[i]){
ll r = t / f[i];
t -= min(r, cnt[i]) * f[i];
cnt[i] -= min(r, cnt[i]);
pq.push(t);
}else{
cnt[i]--;
pq.push(0);
}
}
}
if(pq.top() == 0){
cout << "Yes" << endl;
}else{
cout << "No" << endl;
}
}
misora192