結果
問題 | No.1015 おつりは要らないです |
ユーザー |
![]() |
提出日時 | 2020-04-03 21:55:35 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,207 bytes |
コンパイル時間 | 1,616 ms |
コンパイル使用メモリ | 174,032 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-07-03 02:24:50 |
合計ジャッジ時間 | 3,502 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 27 WA * 6 |
ソースコード
#include <bits/stdc++.h> using namespace std; typedef long long int ll; typedef pair<ll, ll> pll; #define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i)) #define REP(i, n) FOR(i,n,0) #define OF64 std::setprecision(10) const ll MOD = 1000000007; const ll INF = (ll) 1e15; ll N, X, Y, Z; ll A[100005]; bool check() { sort(A, A + N); vector<ll> v; REP(i, N) { ll m = (A[i] + 999) / 1000; ll z = std::min(m / 10, Z); Z -= z; m -= z * 10LL; v.push_back(m); } sort(v.begin(), v.end(), greater<ll>()); REP(i, N) { ll m = v[i]; ll z = std::min((m + 9) / 10, Z); Z -= z; m = std::max(0LL, m - z * 10); ll y = std::min((m + 4) / 5, Y); Y -= y; m = std::max(0LL, m - y * 5); ll x = std::min(X, m); X -= x; m -= x; if (m > 0) return false; } return true; } int main() { cin.tie(0); ios::sync_with_stdio(false); cin >> N >> X >> Y >> Z; REP(i, N) { cin >> A[i]; if (A[i] % 1000 == 0) A[i]++; } if (check()) cout << "Yes" << endl; else cout << "No" << endl; return 0; }