結果

問題 No.1015 おつりは要らないです
ユーザー okok
提出日時 2020-04-03 22:01:55
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,090 bytes
コンパイル時間 863 ms
コンパイル使用メモリ 89,380 KB
実行使用メモリ 5,676 KB
最終ジャッジ日時 2023-09-16 01:36:31
合計ジャッジ時間 3,612 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 WA -
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 56 ms
5,024 KB
testcase_11 AC 59 ms
5,504 KB
testcase_12 AC 54 ms
5,096 KB
testcase_13 AC 56 ms
5,192 KB
testcase_14 AC 59 ms
5,504 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 48 ms
5,292 KB
testcase_21 AC 48 ms
5,160 KB
testcase_22 AC 48 ms
5,176 KB
testcase_23 AC 46 ms
5,072 KB
testcase_24 AC 48 ms
5,384 KB
testcase_25 AC 48 ms
5,072 KB
testcase_26 AC 48 ms
5,144 KB
testcase_27 AC 47 ms
5,100 KB
testcase_28 AC 47 ms
5,232 KB
testcase_29 AC 49 ms
5,032 KB
testcase_30 AC 2 ms
4,380 KB
testcase_31 AC 21 ms
5,508 KB
testcase_32 AC 22 ms
5,444 KB
testcase_33 AC 44 ms
5,460 KB
testcase_34 AC 1 ms
4,376 KB
testcase_35 AC 2 ms
4,376 KB
testcase_36 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<utility>

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

struct fast_io {
	fast_io(){
		std::cin.tie(nullptr);
		std::ios::sync_with_stdio(false);
	};
} ;
// } fio;

bool solve(){
	
	int N, X, Y, Z;
	int sum = 0, con = 0;
	vector<int> A;
	vector<pair<int,int>> B;
	bool flag = true;
	
	cin>>N>>X>>Y>>Z;
	
	A.resize(N);
	B.resize(N);
	
	for(int i = 0; i < N; i++){
		cin>>A[i];
		
		sum += A[i];
		
		con += A[i] / 10000;
		
		B[i] = {A[i] % 10000, A[i]};
	}
	
	if(sum > X * 1000 + Y * 5000 + Z * 10000){
		return false;
		// flag = false;
	}
	
	
	
	// cout<<"con = "<<con<<endl;
	{
		int a, b, c;
		
		a = min(Z, con);
		
		Z   -= a;
		con -= a;
		
		b = min(Y/2, con);
		
		Y   -= b;
		con -= b;
		
		if(Y && X >= 5 && con) {
			Y--;
			X -= 5;
			con--;
		}
		
		c = min(X/10, con);
	
		X   -= c;
		con -= c;
	}
	// cout<<"con = "<<con<<endl;
	
	// cout<<"X = "<<X<<" Y = "<<Y<<" Z = "<<Z<<endl;
	
	if(con) {
		return false;
	}
	
	sort(B.begin(), B.end(), greater<pair<int,int>>());
	
	for(int i = 0; i < Z && i < N; i++){
		B[i] = {0, 0};
	}
	
	sum = 0, con = 0;
	
	for(int i = 0; i < N; i++){
		B[i].second %= 10000;
		
		sum += B[i].second;
		
		con += B[i].second / 5000;
		
		B[i] = {B[i].second % 5000, B[i].second};
	}
	
	// cout<<"con = "<<con<<endl;
	
	sort(B.begin(), B.end(), greater<pair<int,int>>());
	
	if(sum > X * 1000 + Y * 5000 + Z * 10000){
		return false;
	}
	
	{
		int a, b, c;
		
		b = min(Y, con);
		
		Y   -= b;
		con -= b;
		
		
		c = min(X/2, con);
	
		X   -= c;
		con -= c;
	}
	// cout<<"con = "<<con<<endl;
	if(con) {
		return false;
	}
	
	for(int i = 0; i < Y && i < N; i++){
		B[i] = {0, 0};
	}
	
	for(int i = 0; i < N; i++){
		B[i].second %= 5000;
		
		if(B[i].second) {
			X -= (B[i].second + 1000 - 1) / 1000;
		}
	}
	
	if(X < 0) return false;
	
	return true;
}

signed main(){
	
	if(solve()) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}
0