# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
856612 |
2023-10-04T04:44:26 Z |
yash_9a3b |
Bank (IZhO14_bank) |
C++17 |
|
80 ms |
460 KB |
#include "bits/stdc++.h"
#define fast ios_base::sync_with_stdio(0) , cin.tie(0) , cout.tie(0)
#define endl '\n'
#define int long long
#define f first
#define mp make_pair
#define s second
using namespace std;
int n, m;
int p[20], b[20];
signed main()
{
fast;
cin >> n >> m;
for(int i = 0; i < n; i++) cin >> p[i];
for(int i = 0; i < m; i++) cin >> b[i];
if(m <= 10){
sort(b, b + m);
do{
int add = 0, tot = 0;
for(int i = 0; i < m; i++){
tot += b[i];
if(add == n) break;
if(tot > p[add]) break;
if(tot == p[add]) add++, tot = 0;
}
if(add == n){
cout << "YES" << endl; return 0;
}
}while(next_permutation(b, b+m));
cout << "NO" << endl;
}
else{
bool ans = false;
for(int msk = 0; msk < (1 << m); msk++){
int add = 0;
for(int i = 0; i < m; i++) if(msk & (1 << i)) add += b[i];
if(add == p[0]) ans = true;
}
cout << (ans ? "YES" : "NO") << endl;
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
344 KB |
Output is correct |
4 |
Correct |
2 ms |
348 KB |
Output is correct |
5 |
Correct |
69 ms |
432 KB |
Output is correct |
6 |
Correct |
9 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
80 ms |
348 KB |
Output is correct |
9 |
Correct |
69 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
4 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
3 ms |
348 KB |
Output is correct |
5 |
Correct |
18 ms |
460 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
2 ms |
348 KB |
Output is correct |
9 |
Correct |
33 ms |
428 KB |
Output is correct |
10 |
Correct |
3 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
2 ms |
348 KB |
Output is correct |
4 |
Correct |
2 ms |
348 KB |
Output is correct |
5 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
344 KB |
Output is correct |
4 |
Correct |
2 ms |
348 KB |
Output is correct |
5 |
Correct |
69 ms |
432 KB |
Output is correct |
6 |
Correct |
9 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
80 ms |
348 KB |
Output is correct |
9 |
Correct |
69 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
4 ms |
344 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
3 ms |
348 KB |
Output is correct |
14 |
Correct |
18 ms |
460 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
1 ms |
348 KB |
Output is correct |
17 |
Correct |
2 ms |
348 KB |
Output is correct |
18 |
Correct |
33 ms |
428 KB |
Output is correct |
19 |
Correct |
3 ms |
348 KB |
Output is correct |
20 |
Correct |
1 ms |
348 KB |
Output is correct |
21 |
Correct |
1 ms |
348 KB |
Output is correct |
22 |
Correct |
2 ms |
348 KB |
Output is correct |
23 |
Correct |
2 ms |
348 KB |
Output is correct |
24 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
25 |
Halted |
0 ms |
0 KB |
- |