結果

問題 No.1015 おつりは要らないです
ユーザー petite_progpetite_prog
提出日時 2020-04-03 21:42:54
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,881 bytes
コンパイル時間 1,657 ms
コンパイル使用メモリ 174,656 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-16 00:43:53
合計ジャッジ時間 3,590 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 27 ms
4,376 KB
testcase_11 AC 27 ms
4,380 KB
testcase_12 AC 26 ms
4,380 KB
testcase_13 AC 27 ms
4,380 KB
testcase_14 AC 28 ms
4,376 KB
testcase_15 AC 26 ms
4,380 KB
testcase_16 AC 27 ms
4,376 KB
testcase_17 AC 28 ms
4,376 KB
testcase_18 AC 26 ms
4,380 KB
testcase_19 AC 27 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 2 ms
4,376 KB
testcase_31 AC 10 ms
4,380 KB
testcase_32 AC 11 ms
4,376 KB
testcase_33 AC 17 ms
4,380 KB
testcase_34 AC 1 ms
4,376 KB
testcase_35 AC 2 ms
4,376 KB
testcase_36 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

/*
   ∫ ∫ ∫
   ノヽ
  (_  )
 (_    )
(______ )
 ヽ(´・ω・)ノ 
   |  /
   UU
*/
#pragma region macro
#include <bits/stdc++.h>
typedef long long int64;
using namespace std;
using P = pair<int64, int64>;
typedef vector<int> vi;
const int MOD = (int)1e9 + 7;
const int64 INF = 1LL << 62;
const int inf = 1<<30;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i,s,n) for (int i = s; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end() //コンテナじゃないと使えない!!
#define debug(x) cerr << #x << ": " << x << "\n";
#define mp make_pair
#define bn '\n'
template <typename T>
ostream& operator<<(ostream& os, const vector<T> &V){
    int N = V.size();
    REP(i,N){
        os << V[i];
        if (i!=N-1) os << " ";
    }
    os << "\n";
    return os;
}
template <typename T,typename S>
ostream& operator<<(ostream& os, pair<T,S> const&P){
    os << "(";
    os << P.first;
    os << " , ";
    os << P.second;
    os << ")";
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, set<T> &S){
    auto it=S.begin();
    while(it!=S.end()){
        os << *it;
        os << " ";
        it++;
    }
    os << "\n";
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, deque<T> &q){
    for(auto it=q.begin();it<q.end();it++){
        os<<*it;
        os<<" ";
    }
     os<<endl;
    return os;
}
vector<pair<int,int>> dxdy = {mp(0,1),mp(1,0),mp(-1,0),mp(0,-1)};
#pragma endregion
//fixed<<setprecision(10)<<ans<<endl;



int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int64 N,X,Y,Z;
    cin >> N >> X >> Y >> Z;
    vector<int64> A(N);
    REP(i,N) cin >> A[i];
    sort(ALL(A));
    int pay;
    for(auto& a:A){
        if(a>=10000 && Z){
            pay = min(a/10000,Z);
            Z-=pay;
            a-=10000*pay;
        }
        if(a>=5000 && Y){
            pay = min(a/5000,Y);
            Y-=pay;
            a-=5000*pay;
        }
    }

    sort(ALL(A),greater<int64>());
    /*
    5000円札が不足していたら5000以上もあり得る
    1万円札が残っているなら、大きい順にそれで払えばいい
    5000円が残っているなら、大きい順にそれで払えばいい
    残りは1000円で払うしかない
    */
    for(auto& a:A){
        if(a>=0){
            if(Z>0){
                Z--;
                continue;
            }
            if(Y>0){
                Y--;
                continue;
            }
            if(a>=1000*X){
                cout << "No" << bn;
                return 0;
            }
            X-=(a+999)/1000;
        }
    }
    cout << "Yes" << bn;
}
0