結果

問題 No.1015 おつりは要らないです
ユーザー leaf_1415leaf_1415
提出日時 2020-04-06 02:34:56
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 2,035 bytes
コンパイル時間 708 ms
コンパイル使用メモリ 82,848 KB
実行使用メモリ 7,288 KB
最終ジャッジ日時 2023-09-18 11:09:43
合計ジャッジ時間 4,228 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 18 ms
4,792 KB
testcase_11 AC 18 ms
4,716 KB
testcase_12 AC 17 ms
4,816 KB
testcase_13 AC 18 ms
4,788 KB
testcase_14 AC 19 ms
4,792 KB
testcase_15 AC 17 ms
4,772 KB
testcase_16 AC 18 ms
4,792 KB
testcase_17 AC 18 ms
4,752 KB
testcase_18 AC 17 ms
4,780 KB
testcase_19 AC 18 ms
4,764 KB
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 RE -
testcase_30 AC 1 ms
4,376 KB
testcase_31 WA -
testcase_32 AC 15 ms
6,992 KB
testcase_33 AC 18 ms
4,820 KB
testcase_34 AC 2 ms
4,376 KB
testcase_35 AC 1 ms
4,380 KB
testcase_36 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))

using namespace std;
typedef pair<llint, llint> P;

llint n, x, y, z;
llint a[100005];
vector<llint> vec, vec2, vec3, svec;

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n >> x >> y >> z;
	for(int i = 1; i <= n; i++) cin >> a[i], a[i] = (a[i]+1000) / 1000;
	
	for(int i = 1; i <= n; i++){
		llint t = min(z, a[i]/10);
		z -= t;
		a[i] -= t * 10;
	}
	
	if(z == 0){
		for(int i = 1; i <= n; i++){
			llint t = min(y, a[i]/5);
			y -= t;
			a[i] -= t * 5;
			vec.push_back(a[i]);
		}
		sort(vec.rbegin(), vec.rend());
		for(int i = 0; i < vec.size(); i++){
			if(y > 0) y--;
			else x -= vec[i];
		}
		if(x >= 0) cout << "Yes" << endl;
		else cout << "No" << endl;
		return 0;
	}
	
	for(int i = 1; i <= n; i++){
		if(a[i] == 0) continue;
		if(a[i] < 5) vec.push_back(a[i]);
		else vec2.push_back(a[i]);
		vec3.push_back(a[i] % 5);
	}
	if(z > (int)vec.size()){
		cout << "Yes" << endl;
		return 0;
	}
	sort(vec.rbegin(), vec.rend());
	sort(vec2.rbegin(), vec2.rend());
	sort(vec3.rbegin(), vec3.rend());
	
	svec.push_back(0);
	for(int i = 0; i < vec3.size(); i++) svec.push_back(svec.back() + vec3[i]);
	
	for(int i = 0; i <= min(z, (llint)vec2.size()); i++){
		llint len = (int)vec2.size()-i;
		if(len > y){
			llint need = svec.back();
			need += (len - y) * 5;
			if(need <= x){
				cout << "Yes" << endl;
				return 0;
			}
		}
		llint need = svec.back() - svec[y-len];
		if(need <= x){
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	
	return 0;
}
0