結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 33 ms
4,988 KB
testcase_16 AC 33 ms
4,768 KB
testcase_17 AC 35 ms
4,844 KB
testcase_18 AC 34 ms
4,820 KB
testcase_19 AC 33 ms
4,820 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 13 ms
4,992 KB
testcase_32 AC 12 ms
4,936 KB
testcase_33 AC 17 ms
4,936 KB
testcase_34 AC 2 ms
4,380 KB
testcase_35 AC 2 ms
4,376 KB
testcase_36 AC 1 ms
4,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;
        }
        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;
        }
        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