結果
問題 |
No.1015 おつりは要らないです
|
ユーザー |
|
提出日時 | 2020-04-12 16:47:28 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 36 ms / 2,000 ms |
コード長 | 1,573 bytes |
コンパイル時間 | 1,352 ms |
コンパイル使用メモリ | 118,912 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-18 05:48:48 |
合計ジャッジ時間 | 3,461 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 33 |
ソースコード
#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; }