結果

問題 No.1015 おつりは要らないです
ユーザー erbowlerbowl
提出日時 2020-04-04 09:21:23
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 31 ms / 2,000 ms
コード長 1,545 bytes
コンパイル時間 2,182 ms
コンパイル使用メモリ 174,284 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-29 01:23:42
合計ジャッジ時間 3,247 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

typedef long long ll;
#include <bits/stdc++.h>
using namespace std;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll n,x,y,z;
    std::cin >> n>>x>>y>>z;
    
    vector<ll> a(n);
    for (int i = 0; i < n; i++) {
        std::cin >> a[i];
    }
    
    priority_queue<ll> pq;
    for (int i = 0; i < n; i++) {
        pq.push((a[i]+1000)/1000);
    }
    
    while(pq.size()&&z>0){
        auto now = pq.top();pq.pop();
        if(now<=10){
            z--;
            continue;
        }
        if(now/10 <= z ){
            z -= now/10;
            now %= 10;
        }else{
            now -= z*10;
            z = 0;
        }
        if(now!=0)pq.push(now);
    }
    if(pq.size()==0){
        std::cout << "Yes" << std::endl;
        return 0;
    }
    while(pq.size()&&y>0){
        auto now = pq.top();pq.pop();
        if(now<=5){
            y--;
            continue;
        }
        if(now/5 <= y ){
            y -= now/5;
            now %= 5;
        }else{
            now -= y*5;
            y = 0;
        }
        if(now!=0)pq.push(now);
    }
    
    if(pq.size()==0){
        std::cout << "Yes" << std::endl;
        return 0;
    }
    
    while(pq.size()&&x>0){
        auto now = pq.top();pq.pop();
        if(x>=now){
            x -= now;
            continue;
        }else{
            std::cout << "No" << std::endl;
            return 0;
        }
    }
    if(pq.size()==0){
        std::cout << "Yes" << std::endl;
    }else{
        std::cout << "No" << std::endl;
    }

}

0