結果

問題 No.1015 おつりは要らないです
ユーザー RubikunRubikun
提出日時 2020-04-03 21:35:19
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 21 ms / 2,000 ms
コード長 1,719 bytes
コンパイル時間 1,714 ms
コンパイル使用メモリ 172,308 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-11 08:37:51
合計ジャッジ時間 3,614 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=200005,INF=1<<30;

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N;cin>>N;
    ll X,Y,Z;cin>>X>>Y>>Z;
    vector<ll> A(N);
    for(int i=0;i<N;i++) cin>>A[i];
    bool ok=true;
    
    for(int i=0;i<N;i++){
        ll a=A[i]/10000;
        A[i]%=10000;
        if(a==0) continue;
        if(Z>=a){
            Z-=a;
        }else{
            a-=Z;
            Z=0;
            a*=2;
            
            if(Y>=a){
                Y-=a;
            }else{
                a-=Y;
                Y=0;
                a*=5;
                
                if(X>=a){
                    X-=a;
                }else{
                    ok=false;
                }
            }
        }
    }
    
    for(int i=0;i<N;i++){
        ll a=A[i]/5000;
        A[i]%=5000;
        if(a==0) continue;
        if(Z>=a){
            Z-=a;
            A[i]=-1;
        }else{
            if(Y>=a){
                Y-=a;
            }else{
                a*=5;
                
                if(X>=a){
                    X-=a;
                }else{
                    ok=false;
                }
            }
        }
    }
    
    sort(all(A));
    reverse(all(A));
    
    for(int i=0;i<N;i++){
        if(A[i]==-1) continue;
        if(Z) Z--;
        else{
            if(Y){
                Y--;
            }else{
                X-=(A[i]/1000+1);
                if(X<0) ok=false;
            }
        }
    }
    
    if(ok) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

0