結果

問題 No.1015 おつりは要らないです
ユーザー 👑 jupirojupiro
提出日時 2020-04-12 16:47:28
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 35 ms / 2,000 ms
コード長 1,573 bytes
コンパイル時間 1,158 ms
コンパイル使用メモリ 119,176 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-29 05:09:34
合計ジャッジ時間 2,841 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 1 ms
5,376 KB
testcase_08 AC 1 ms
5,376 KB
testcase_09 AC 1 ms
5,376 KB
testcase_10 AC 31 ms
5,376 KB
testcase_11 AC 32 ms
5,376 KB
testcase_12 AC 31 ms
5,376 KB
testcase_13 AC 32 ms
5,376 KB
testcase_14 AC 33 ms
5,376 KB
testcase_15 AC 32 ms
5,376 KB
testcase_16 AC 34 ms
5,376 KB
testcase_17 AC 35 ms
5,376 KB
testcase_18 AC 34 ms
5,376 KB
testcase_19 AC 33 ms
5,376 KB
testcase_20 AC 27 ms
5,376 KB
testcase_21 AC 26 ms
5,376 KB
testcase_22 AC 27 ms
5,376 KB
testcase_23 AC 26 ms
5,376 KB
testcase_24 AC 27 ms
5,376 KB
testcase_25 AC 26 ms
5,376 KB
testcase_26 AC 27 ms
5,376 KB
testcase_27 AC 26 ms
5,376 KB
testcase_28 AC 26 ms
5,376 KB
testcase_29 AC 25 ms
5,376 KB
testcase_30 AC 1 ms
5,376 KB
testcase_31 AC 16 ms
5,376 KB
testcase_32 AC 16 ms
5,376 KB
testcase_33 AC 24 ms
5,376 KB
testcase_34 AC 1 ms
5,376 KB
testcase_35 AC 2 ms
5,376 KB
testcase_36 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>
#include <numeric>

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

constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int inf = 1 << 28;
//constexpr long long mod = 1000000007LL;
//constexpr long long mod = 998244353LL;

using namespace std;
typedef unsigned long long ull;
typedef long long ll;

void f(ll money, vector<ll>& a, ll cnt) {
	int n = a.size();
	for (int i = 0; i < n; i++) {
		if (a[i] >= money) {
			ll mn = min(a[i] / money, cnt);
			a[i] -= mn * money;
			cnt -= mn;
		}
	}
	sort(a.rbegin(), a.rend());
	for (int i = 0; i < n; i++) {
		if (a[i] > 0 and cnt > 0) {
			a[i] = 0;
			cnt--;
		}
	}
}

int main()
{
	/*
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	*/

	ll n, x, y, z; scanf("%lld %lld %lld %lld", &n, &x, &y, &z);
	vector<ll> a(n); for (int i = 0; i < n; i++) scanf("%lld", &a[i]), a[i]++;
	f(10000, a, z);
	f(5000, a, y);
	f(1000, a, x);
	sort(a.rbegin(), a.rend());
	if (a[0] == 0) puts("Yes");
	else puts("No");
	return 0;
}
0