結果

問題 No.1015 おつりは要らないです
ユーザー NewGardenNewGarden
提出日時 2020-04-03 22:03:10
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,646 bytes
コンパイル時間 1,531 ms
コンパイル使用メモリ 171,464 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-16 01:40:39
合計ジャッジ時間 4,090 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 44 ms
4,376 KB
testcase_11 AC 45 ms
4,380 KB
testcase_12 AC 43 ms
4,384 KB
testcase_13 AC 44 ms
4,376 KB
testcase_14 AC 45 ms
4,380 KB
testcase_15 AC 43 ms
4,376 KB
testcase_16 AC 44 ms
4,384 KB
testcase_17 AC 47 ms
4,376 KB
testcase_18 AC 44 ms
4,376 KB
testcase_19 AC 44 ms
4,380 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 1 ms
4,380 KB
testcase_31 AC 18 ms
4,376 KB
testcase_32 AC 17 ms
4,376 KB
testcase_33 AC 43 ms
4,380 KB
testcase_34 WA -
testcase_35 AC 1 ms
4,376 KB
testcase_36 AC 0 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=8010;
const ll mod=1e9+7;
 
int main(){
  int n;
  ll x,y,z;
  cin >> n >> x >> y >> z;
  vector<ll> a(n);
  rep(i,n) cin>>a[i];
  rep(i,n){
    ll k = a[i]/10000;
    a[i] %= 10000;
    if(a[i]==0) a[i]++;
    if(z>=k){
      z -= k;
    } else {
      k -= z;
      z=0;
      a[i] += 10000*k;
    }
  }
  sort(a.rbegin(),a.rend());
  rep(i,n){
    ll k = a[i]/10000;
    a[i] %= 10000;
    if(a[i]==0) a[i]++;
    if(z>=k){
      z -= k;
    } else {
      k -= z;
      z=0;
      a[i] += 10000*k;
    }

    k = a[i]/5000;
    a[i] %= 5000;
    if(a[i]==0) a[i]++;
    if(y>=k){
      y -= k;
    } else {
      k -= y;
      y=0;
      a[i] += 5000*k;
    }

    k = (a[i]+999)/1000;
    if(x>=k){
      x -= k;
    } else {
//      k -= x;
//      a[i] -= 1000*x;
//      x=0;
      if(a[i]%10000<=5000 && y>0){
        y--;
        a[i] -= 5000;
        if(a[i]<=0) continue;
      }
      k = (a[i]+9999)/10000;
      if(z>=k){
        z -= k;
      } else {
        a[i] -= 10000*z;
        z=0;

        k = (a[i]+4999)/5000;
        if(y>=k){
          y -= k;
        } else {
          a[i] -= 5000*y;
          y=0;

          k = (a[i]+999)/1000;
          if(x>=k){
            x -= k;
          } else {
            cout << "No" << endl; return 0;
          }
        }
      }
    }
  }
  cout << "Yes" << endl;
  return 0;
}
0