# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
794942 |
2023-07-27T04:17:56 Z |
nguyennehehe |
Bank (IZhO14_bank) |
C++14 |
|
1000 ms |
316 KB |
#include<bits/stdc++.h>
using namespace std;
const int N = 20;
int n, m, a[N], b[N];
void sub1() {
bool ok = false;
for (int s = 1; s < (1 << m); ++s) {
int sum = 0;
for (int i = 0; i < m; ++i) {
if (s >> i & 1) sum += b[i];
}
ok |= sum == a[0];
}
cout << (ok ? "YES" : "NO");
}
void sub2() {
bool good = false;
do {
bool ok = true;
for (int i = 0, j = 0; i < n; ++i) {
int sum = 0;
while (j < m && sum < a[i]) {
sum += b[j];
j += 1;
}
ok &= sum == a[i];
}
good |= ok;
if (good) break;
} while (next_permutation(b, b + m));
cout << (good ? "YES": "NO");
}
signed main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cin >> n >> m;
for (int i = 0; i < n; ++i) cin >> a[i];
for (int i = 0; i < m; ++i) cin >> b[i];
sub2();
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
3 ms |
212 KB |
Output is correct |
5 |
Correct |
15 ms |
316 KB |
Output is correct |
6 |
Incorrect |
4 ms |
212 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1068 ms |
212 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |