結果

問題 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
コンパイル時間 920 ms
コンパイル使用メモリ 98,292 KB
実行使用メモリ 5,804 KB
最終ジャッジ日時 2023-08-11 08:37:59
合計ジャッジ時間 3,332 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 33 ms
5,508 KB
testcase_11 AC 34 ms
5,744 KB
testcase_12 AC 32 ms
5,764 KB
testcase_13 AC 34 ms
5,528 KB
testcase_14 AC 35 ms
5,704 KB
testcase_15 AC 32 ms
5,496 KB
testcase_16 AC 34 ms
5,524 KB
testcase_17 AC 34 ms
5,664 KB
testcase_18 AC 33 ms
5,672 KB
testcase_19 AC 33 ms
5,596 KB
testcase_20 AC 35 ms
5,592 KB
testcase_21 AC 34 ms
5,672 KB
testcase_22 AC 34 ms
5,724 KB
testcase_23 AC 33 ms
5,484 KB
testcase_24 AC 35 ms
5,744 KB
testcase_25 AC 34 ms
5,520 KB
testcase_26 AC 33 ms
5,608 KB
testcase_27 AC 34 ms
5,804 KB
testcase_28 AC 34 ms
5,488 KB
testcase_29 AC 35 ms
5,580 KB
testcase_30 AC 2 ms
4,380 KB
testcase_31 AC 13 ms
5,796 KB
testcase_32 AC 13 ms
5,572 KB
testcase_33 AC 21 ms
5,644 KB
testcase_34 AC 1 ms
4,380 KB
testcase_35 AC 2 ms
4,376 KB
testcase_36 AC 2 ms
4,380 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