結果

問題 No.1015 おつりは要らないです
ユーザー idat_50meidat_50me
提出日時 2020-04-03 22:19:34
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 3,884 bytes
コンパイル時間 1,782 ms
コンパイル使用メモリ 177,568 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-09-16 02:31:42
合計ジャッジ時間 4,230 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 34 ms
4,376 KB
testcase_16 AC 35 ms
4,376 KB
testcase_17 AC 36 ms
4,376 KB
testcase_18 AC 36 ms
4,380 KB
testcase_19 AC 35 ms
4,376 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 2 ms
4,376 KB
testcase_31 AC 14 ms
4,376 KB
testcase_32 AC 15 ms
4,380 KB
testcase_33 AC 40 ms
4,376 KB
testcase_34 AC 2 ms
4,376 KB
testcase_35 AC 2 ms
4,376 KB
testcase_36 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: 関数 ‘ll GreaterBinarySearch(ll*, ll, ll, ll)’ 内:
main.cpp:77:24: 警告: NULL から非ポインタ型 ‘ll’ {aka ‘long long int’} へ変換しています [-Wconversion-null]
   77 |                 return NULL;
      |                        ^~~~

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using intpair=pair<int,int>;
using llpair=pair<ll,ll>;
using llvec=vector<ll>;
using llmat=vector<vector<ll>>;
#define PI 3.141592653589793
#define llmattp(name,a,b,num) name(a,vector<ll>(b,num))
#define INTINF 1<<30
#define LLINF 1LL<<60
#define ABS(x) ( (x)>0 ? (x) : -(x) )
#define gsort(vbeg,vend) sort(vbeg,vend,greater<>())

template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}

template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

ll gcd(ll a, ll b) { //最大公約数
	if(a==0||b==0) return 0;
	if(a<b) swap(a,b);
	ll tmp = a%b;
	while(tmp!=0) {
		a = b;
		b = tmp;
		tmp = a%b;
	}
	return b;
}

ll factorial(ll x) { //階乗
	ll f=1;
	for(ll i=2; i<x; i++) {
		f*=i;
	}
	return f;
}

ll nPr(ll n, ll r) {
	ll result=1;
	for(ll i=r+1; i<=n; i++) result*=i;
	return result;
}

ll nCr(ll n, ll r) {
	if (n == r) { return 1; }
	if (r > n) { return 0; }

	if (r > n / 2) { r = n - r; }

	if (n == 0) { return 0; }
	if (r == 0) { return 1; }
	if (r == 1) { return n; }

	double result = 1;
	for (double i = 1; i <= r; i++) {
		result *= (n - i + 1) / i;
	}

	return (ll)result;
}

ll GreaterBinarySearch(ll *array, ll key, ll max, ll min) { //にぶたんgreater
	if(array[max]<array[min]) {
		return NULL;
	} else {
		ll mid = max + (min-max)/2;
		if(array[mid]<key) {
			return GreaterBinarySearch(array,key,max,mid-1);
		} if(array[mid]>key) {
			return GreaterBinarySearch(array,key,mid+1,min);
		} else {
			return mid;
		}
	}
}

int DigitNum(ll n) { //桁数
	int digit=0;
	ll wari=1LL;
	while(n/wari) {
		digit++;
		wari*=10;
	}
	return digit;
}

bool IsPrime(ll num) { //素数判定
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

	double sqrtNum = sqrt(num);
	for (ll i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			// 素数ではない
			return false;
		}
	}

	// 素数である
	return true;
}

vector<ll> Divisor(ll x) { // 約数列挙
	vector<ll> result;
	ll i=1LL;
	for( ; i*i<x; i++) {
		if(x%i) continue;
		result.push_back(i);
		result.push_back(x/i);
	}
	if(i*i==x&&x%i==0)
		result.push_back(i);
	
	sort(result.begin(),result.end());
	return result;
}

vector<llpair> PrimeFact(ll x) { // 素因数分解 {素因数,指数}
	vector<llpair> result;
	ll ex=0LL;
	if(x%2==0) {
		while(x%2==0) {
			x/=2;
			ex++;
		}
		result.push_back({2,ex});
	}

	for(ll i=3LL; i*i<=x; i+=2) {
		if(x%i) continue;

		ex=0LL;
		while(x%i==0) {
			x/=i;
			ex++;
		}
		result.push_back({i,ex});
	}

	if(x!=1) result.push_back({x,1});

	return result;
}

bool Palind(string s) { //回文判定
	return s == string(s.rbegin(), s.rend());
}


int main() {
	ll N,X,Y,Z; cin>>N>>X>>Y>>Z;
	int turi[10]; for(int i=0; i<10; i++) turi[i]=0LL;
	ll msatu=0LL;
	for(int i=0; i<N; i++) {
		int A; cin>>A;
		msatu+=A/10000;
		A%=10000;
		turi[A/1000]++;
	}
	msatu+=turi[9];
	turi[9]=0;

	if(Z>=msatu) {
		Z-=msatu;
	}
	else {
		Z=0;
		msatu-=Z;
		if(Y>=msatu*2) {
			Y-=msatu*2;
		}
		else {
			Y=msatu%2;
			msatu-=Y/2;
			if(X>=msatu*10) {
				X-=msatu*10;
			}
			else {
				cout<<"No"<<endl;
				return 0;
			}
		}
	}

	int gsatu=turi[4]+turi[5]+turi[6]+turi[7]+turi[8];
	if(Z>=gsatu) {
		Z-=gsatu;
	}
	else {
		Z=0;
		gsatu-=Z;
		if(Y>=gsatu) {
			Y-=gsatu;
		}
		else {
			Y=0;
			gsatu-=Y;
			if(X>=gsatu*5) {
				X-=msatu*5;
			}
			else {
				cout<<"No"<<endl;
				return 0;
			}
		}
	}

	for(int i=3; i>=0; i--) {
		if(turi[i]<=Z+Y) {
			if(turi[i]<=Z) {
				Z-=turi[i];
			}
			else {
				Z=0;
				Y-=turi[i]-Z;
			}
			turi[i]=0;
		}
		else {
			turi[i]-=Z+Y;
			Z=0;
			Y=0;
		}
	}

	ll isatu=turi[0]+turi[1]*2+(ll)turi[2]*3+(ll)turi[3]*4;
	if(X>=isatu)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
}
0