| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 879808 | The_Samurai | 은행 (IZhO14_bank) | C++17 | 1 ms | 356 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
// I stand with PALESTINE
//#pragma GCC optimize("Ofast,O3")
//#pragma GCC target("avx,avx2")
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
void solve() {
int n, m;
cin >> m >> n;
vector<int> a(n), b(m);
for (int &x: b) cin >> x;
for (int &x: a) cin >> x;
sort(a.rbegin(), a.rend());
sort(b.rbegin(), b.rend());
for (int i = 0; i < m; i++) {
vector<int> came(b[i] + 1, -1);
came[0] = 0;
for (int j = 0; j < a.size(); j++) {
for (int x = b[i]; x >= a[j]; x--) {
if (came[x] == -1 and came[x - a[j]] != -1) {
came[x] = a[j];
}
}
}
if (came[b[i]] == -1) {
cout << "NO";
return;
}
int x = b[i];
while (x != 0) {
a.erase(find(a.begin(), a.end(), came[x]));
x -= came[x];
}
// for (int x: a) cout << x << ' ';
// cout << endl;
}
cout << "YES";
}
int main() {
cin.tie(0)->sync_with_stdio(false);
#ifdef sunnatov
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
int q = 1;
// cin >> q;
while (q--) {
solve();
cout << '\n';
}
}컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
