結果

問題 No.1015 おつりは要らないです
ユーザー polyester
提出日時 2020-04-03 22:04:26
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 854 bytes
コンパイル時間 735 ms
コンパイル使用メモリ 82,940 KB
実行使用メモリ 10,752 KB
最終ジャッジ日時 2024-07-03 02:57:22
合計ジャッジ時間 20,600 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3 WA * 1
other AC * 20 WA * 9 TLE * 1 -- * 3
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cstdio>
using namespace std;
using ll = long long;
int main(){
  int n, x, y, z;
  cin >> n >> x >> y >> z;
  bool ok = true;
  for(int i = 0; i < n; i++) {
    int a;
    cin >> a;
    while(a > 0){
      if(a >= 10000 && z > 0){
        a -= 10000;
        x--;
      }else if(a >= 5000 && y > 0){
        a -= 5000;
        y--;
      }else if(x > 0){
        a -= 1000;
        x--;
      }else if(y > 0){
        a -= 5000;
        y--;
      }else if(z > 0){
        a -= 10000;
        z--;
      }
      if(x == 0 && y == 0 && z == 0){
        ok = false;
        break;
      }
    }
  }
  if(!ok){
    cout << "No\n";
  }else{
    cout << "Yes\n";
  }
  return 0;
}
0