結果

問題 No.1015 おつりは要らないです
ユーザー fura
提出日時 2020-06-02 19:06:44
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 667 bytes
コンパイル時間 2,110 ms
コンパイル使用メモリ 197,916 KB
最終ジャッジ日時 2025-01-10 20:37:15
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 15 WA * 18
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:8:27: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    8 |         int n,x,y,z; scanf("%d%d%d%d",&n,&x,&y,&z);
      |                      ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
main.cpp:12:29: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   12 |                 int a; scanf("%d",&a);
      |                        ~~~~~^~~~~~~~~

ソースコード

diff #

#include <bits/stdc++.h>

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

int main(){
	int n,x,y,z; scanf("%d%d%d%d",&n,&x,&y,&z);

	priority_queue<int> Q;
	rep(i,n){
		int a; scanf("%d",&a);
		Q.emplace(a+1);
	}

	while(z>0 && !Q.empty()){
		int a=Q.top(); Q.pop();
		int k=min((a+9999)/10000,z);
		a-=10000*k;
		if(a>0) Q.emplace(a);
		z-=k;
	}
	while(y>0 && !Q.empty()){
		int a=Q.top(); Q.pop();
		int k=min((a+4999)/5000,y);
		a-=5000*k;
		if(a>0) Q.emplace(a);
		y-=k;
	}
	while(x>0 && !Q.empty()){
		int a=Q.top(); Q.pop();
		int k=min((a+999)/1000,x);
		a-=1000*k;
		if(a>0) Q.emplace(a);
		x-=k;
	}

	puts(Q.empty()?"Yes":"No");

	return 0;
}
0