# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
331544 |
2020-11-28T21:06:17 Z |
jovan_b |
Bank (IZhO14_bank) |
C++17 |
|
104 ms |
8684 KB |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
pair <int, int> dp[2000005];
int a[25];
int b[25];
int main(){
ios_base::sync_with_stdio(false);
cout.precision(10);
cout << fixed;
int n, m;
cin >> n >> m;
for(int i=1; i<=n; i++){
cin >> a[i];
}
for(int j=0; j<m; j++){
cin >> b[j];
}
for(int mask=0; mask<(1<<m); mask++){
for(int i=0; i<m; i++){
if((1<<i)&mask) continue;
int k = a[dp[mask].first+1] - dp[mask].second;
if(k < b[i]) continue;
else if(k == b[i]) dp[mask|(1<<i)] = {dp[mask].first+1, 0};
else dp[mask|(1<<i)] = {dp[mask].first, dp[mask].second+b[i]};
}
}
for(int i=0; i<(1<<m); i++){
if(dp[i].first == n){
cout << "YES\n";
return 0;
}
}
cout << "NO\n";
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
0 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
3 ms |
620 KB |
Output is correct |
5 |
Correct |
89 ms |
8556 KB |
Output is correct |
6 |
Correct |
1 ms |
492 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
104 ms |
8556 KB |
Output is correct |
9 |
Correct |
87 ms |
8684 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
492 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
0 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
3 ms |
620 KB |
Output is correct |
5 |
Correct |
89 ms |
8556 KB |
Output is correct |
6 |
Correct |
1 ms |
492 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
104 ms |
8556 KB |
Output is correct |
9 |
Correct |
87 ms |
8684 KB |
Output is correct |
10 |
Correct |
1 ms |
364 KB |
Output is correct |
11 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
12 |
Halted |
0 ms |
0 KB |
- |