結果

問題 No.1015 おつりは要らないです
ユーザー 👑 CleyL
提出日時 2022-12-30 14:40:17
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 73 ms / 2,000 ms
コード長 1,099 bytes
コンパイル時間 755 ms
コンパイル使用メモリ 76,708 KB
最終ジャッジ日時 2025-02-09 22:05:32
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 33
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <queue>

using namespace std;

int main(){
  long long n,x,y,z;cin>>n>>x>>y>>z;
  priority_queue<long long> A;
  for(int i = 0; n > i; i++){
    long long s;cin>>s;
    A.push(s+1);
  }
  while(A.size()){
    auto k = A.top();A.pop();
    if(10000 < k && z){
      long long use = min(k/10000,z);
      if(k != 10000*use)A.push(k-10000*use);
      z -= use;
      continue;
    }
    if(5000 < k){
      if(z){
        z--;
        continue;
      }
      if(y){
        long long use = min(k/5000,y);

        if(k != 5000*use)A.push(k-5000*use);
        y -= use;
        continue;
      }
    }
    if(1000 < k){
      if(z){
        z--;
        continue;
      }
      if(y){
        y--;
        continue;
      }
      if(x){
        long long use = min(k/1000,x);
        if(k != 1000*use)A.push(k-1000*use);
        x -= use;
        continue;
      }
    }
    if(z){
      z--;
      continue;
    }
    if(y){
      y--;
      continue;
    }
    if(x){
      x--;
      continue;
    }
    cout << "No" << endl;
    return 0;
  }
  cout << "Yes" << endl;
}
0