結果
| 問題 | No.1015 おつりは要らないです |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-11-09 22:01:42 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,887 bytes |
| 記録 | |
| コンパイル時間 | 1,187 ms |
| コンパイル使用メモリ | 106,700 KB |
| 最終ジャッジ日時 | 2025-01-15 21:52:46 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 22 WA * 11 |
ソースコード
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <cstdio>
#include <limits>
#define rep(i,n) for(int i = 0; i < n; ++i)
#define rep1(i,n) for(int i = 1; i <= n; ++i)
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if(a < b){ a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if(a > b){ a = b; return 1; } return 0; }
template<class T> inline int sz(T &a) { return a.size(); }
using ll = long long; using ld = long double;
using pi = pair<int,int>; using pl = pair<ll,ll>;
using vi = vector<int>; using vvi = vector<vi>;
using vl = vector<ll>; using vvl = vector<vl>;
const int inf = numeric_limits<int>::max();
const ll infll = numeric_limits<ll>::max();
int main()
{
int n; cin >> n;
ll x,y,z; cin >> x >> y >> z;
vl a(n);
rep(i,n) cin >> a[i];
rep(i,n) {
a[i] = (a[i] / 1000 + 1) * 1000;
}
vector<pl> p(n);
rep(i,n) {
p[i] = {(a[i] % 5000) / 1000 , a[i]};
}
sort(p.begin(), p.end());
int id = 0;
while(id < n && x - p[id].first >= 0) {
x -= p[id].first;
p[id].second -= p[id].first * 1000;
id++;
}
if(x > 0) y += x / 5;
while(id < n) {
if(p[id].first != 0) p[id].second = (p[id].second / 5000 + 1) * 5000;
id++;
}
rep(i,n) {
p[i] = {(p[i].second % 10000) / 5000, p[i].second};
}
id = 0;
while(id < n && y - p[id].first >= 0) {
y -= p[id].first;
p[id].second -= p[id].first * 5000;
id++;
}
if(y > 0) z += y / 2;
while(id < n) {
if(p[id].first != 0) p[id].second += 5000;
id++;
}
rep(i,n) {
p[i] = {p[i].second / 10000, 0};
}
id = 0;
while(id < n && z - p[id].first >= 0) {
z -= p[id].first;
id++;
}
if(id == n) cout << "Yes" << "\n";
else cout << "No" << "\n";
return 0;
}