結果
| 問題 |
No.1015 おつりは要らないです
|
| コンテスト | |
| ユーザー |
ゆきのん
|
| 提出日時 | 2020-04-15 17:45:25 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 64 ms / 2,000 ms |
| コード長 | 2,217 bytes |
| コンパイル時間 | 1,780 ms |
| コンパイル使用メモリ | 174,592 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-11-18 07:18:41 |
| 合計ジャッジ時間 | 3,910 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 33 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a,T b){return b?gcd(b,a%b):a;}
const LL mod=1000000007;
const LL LINF=1LL<<62;
const int INF=1<<30;
int dx[]={1,0,-1,0,1,-1,1,-1};
int dy[]={0,1,0,-1,1,-1,-1,1};
bool solve(){
int n;cin >> n;
vector<LL> x(3,0);
cin >> x[0] >> x[1] >> x[2];
priority_queue<LL> pq;
for (int i = 0; i < n; i++) {
LL a;cin >> a;
pq.push(a);
}
while(not pq.empty()){
if(x[2]){
LL t = pq.top();pq.pop();
LL c = t / 10000;
if(c == 0) c = 1;
if(c <= x[2]){
x[2] -= c;
t -= 10000 * c;
if(t >= 0) pq.push(t);
}
else{
t -= 10000 * x[2];
x[2] = 0;
if(t >= 0) pq.push(t);
}
}
else if(x[1]){
LL t = pq.top();pq.pop();
LL c = t / 5000;
if(c == 0) c = 1;
if(c <= x[1]){
x[1] -= c;
t -= 5000 * c;
if(t >= 0) pq.push(t);
}
else{
t -= 5000 * x[1];
x[1] = 0;
if(t >= 0) pq.push(t);
}
}
else if(x[0]){
LL t = pq.top();pq.pop();
LL c = t / 1000;
if(c == 0) c = 1;
if(c <= x[0]){
x[0] -= c;
t -= 1000 * c;
if(t >= 0) pq.push(t);
}
else{
t -= 1000 * x[0];
x[0] = 0;
if(t >= 0) pq.push(t);
}
}
else{
return false;
}
}
return true;
}
int main(){
if(solve()) puts("Yes");
else puts("No");
return 0;
}
ゆきのん