結果

問題 No.1015 おつりは要らないです
ユーザー snow39snow39
提出日時 2020-04-03 21:35:52
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 35 ms / 2,000 ms
コード長 1,443 bytes
コンパイル時間 929 ms
コンパイル使用メモリ 99,436 KB
実行使用メモリ 6,116 KB
最終ジャッジ日時 2024-04-29 01:10:38
合計ジャッジ時間 2,875 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 33 ms
5,948 KB
testcase_11 AC 34 ms
5,984 KB
testcase_12 AC 32 ms
6,020 KB
testcase_13 AC 34 ms
5,816 KB
testcase_14 AC 33 ms
6,020 KB
testcase_15 AC 32 ms
5,908 KB
testcase_16 AC 34 ms
5,820 KB
testcase_17 AC 34 ms
6,116 KB
testcase_18 AC 33 ms
5,940 KB
testcase_19 AC 33 ms
5,800 KB
testcase_20 AC 35 ms
5,968 KB
testcase_21 AC 34 ms
5,824 KB
testcase_22 AC 34 ms
5,820 KB
testcase_23 AC 33 ms
5,900 KB
testcase_24 AC 34 ms
5,848 KB
testcase_25 AC 34 ms
5,948 KB
testcase_26 AC 34 ms
6,076 KB
testcase_27 AC 34 ms
5,928 KB
testcase_28 AC 33 ms
5,928 KB
testcase_29 AC 34 ms
5,836 KB
testcase_30 AC 2 ms
5,376 KB
testcase_31 AC 13 ms
5,888 KB
testcase_32 AC 13 ms
6,020 KB
testcase_33 AC 21 ms
6,024 KB
testcase_34 AC 2 ms
5,376 KB
testcase_35 AC 2 ms
5,376 KB
testcase_36 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
template<class T> void chmin(T &a,const T &b){if(a>b) a=b;}
template<class T> void chmax(T &a,const T &b){if(a<b) a=b;}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);

  int N;
  ll X,Y,Z;
  cin>>N>>X>>Y>>Z;
  vector<ll> A(N);
  rep(i,N) cin>>A[i];

  vector<ll> B(N);
  rep(i,N) B[i]=A[i]/1000+1;
  
  priority_queue<ll> PQ;
  rep(i,N) PQ.push(B[i]);

  //10,000
  while(!PQ.empty()){
    if(Z==0) break;
    auto f=PQ.top();
    PQ.pop();
    ll num=f/10;
    if(num==0){
      Z--; 
    }else{
      if(Z>=num){
        Z-=num;
        if(f%10) PQ.push(f%10);
      }else{
        num-=Z;
        PQ.push(num*10+f%10);
        Z=0;
      }
    }
  }

  //5,000
  while(!PQ.empty()){
    if(Y==0) break;
    auto f=PQ.top();
    PQ.pop();
    ll num=f/5;
    if(num==0) Y--;
    else{
      if(Y>=num){
        Y-=num;
        if(f%5) PQ.push(f%5);
      }else{
        num-=Y;
        PQ.push(num*5+f%5);
        Y=0;
      }
    }
  }

  ll rest=0;
  while(!PQ.empty()){
    auto f=PQ.top();
    PQ.pop();
    rest+=f;
  }

  if(X>=rest) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;

  return 0;
}
0