# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
331897 |
2020-11-30T16:17:07 Z |
vitkishloh228 |
Bank (IZhO14_bank) |
C++14 |
|
1000 ms |
90652 KB |
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
const int maxc = 20000 + 1;
int main() {
int n, m;
cin >> n >> m;
vector<int> a(n), b(m);
for (int& i : a) cin >> i;
for (int& i : b) cin >> i;
vector<int> pr(n + 1);
for (int i = 0; i < n; ++i) {
pr[i + 1] = pr[i] + a[i];
}
vector<int> summask((1 << m));
for (int mask = 0; mask < (1 << m); ++mask) {
for (int i = 0; i < m; ++i) {
if ((mask & (1 << i))) {
summask[mask] += b[i];
}
}
}
vector<int> needmask = { 0 };
vector<vector<int>> dp(n, vector<int>(1 << m));
for (int i = 0; i < n; ++i) {
int needsum = pr[i];
vector<int> q;
for (int mask = 0; mask < (1 << m); ++mask) {
if (summask[mask] != pr[i + 1]) {
continue;
}
for (auto mask1 : needmask) {
if ((mask & mask1) == mask1) {
dp[i][mask] = 1;
q.push_back(mask);
break;
}
}
}
swap(needmask, q);
}
for (int i = 0; i < (1 << m); ++i) {
if (dp[n - 1][i]) {
cout << "YES";
return 0;
}
}
cout << "NO";
}
Compilation message
bank.cpp: In function 'int main()':
bank.cpp:27:13: warning: unused variable 'needsum' [-Wunused-variable]
27 | int needsum = pr[i];
| ^~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
3 ms |
748 KB |
Output is correct |
5 |
Correct |
75 ms |
12652 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
76 ms |
12652 KB |
Output is correct |
9 |
Correct |
75 ms |
12652 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
1 ms |
364 KB |
Output is correct |
9 |
Correct |
1 ms |
364 KB |
Output is correct |
10 |
Correct |
1 ms |
364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
1004 KB |
Output is correct |
2 |
Correct |
2 ms |
620 KB |
Output is correct |
3 |
Correct |
2 ms |
1132 KB |
Output is correct |
4 |
Correct |
2 ms |
1388 KB |
Output is correct |
5 |
Correct |
2 ms |
1152 KB |
Output is correct |
6 |
Correct |
2 ms |
748 KB |
Output is correct |
7 |
Correct |
2 ms |
748 KB |
Output is correct |
8 |
Correct |
2 ms |
620 KB |
Output is correct |
9 |
Correct |
2 ms |
1004 KB |
Output is correct |
10 |
Correct |
3 ms |
1004 KB |
Output is correct |
11 |
Correct |
2 ms |
1388 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
3 ms |
748 KB |
Output is correct |
5 |
Correct |
75 ms |
12652 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
76 ms |
12652 KB |
Output is correct |
9 |
Correct |
75 ms |
12652 KB |
Output is correct |
10 |
Correct |
1 ms |
364 KB |
Output is correct |
11 |
Correct |
1 ms |
364 KB |
Output is correct |
12 |
Correct |
1 ms |
364 KB |
Output is correct |
13 |
Correct |
1 ms |
364 KB |
Output is correct |
14 |
Correct |
1 ms |
364 KB |
Output is correct |
15 |
Correct |
1 ms |
364 KB |
Output is correct |
16 |
Correct |
1 ms |
364 KB |
Output is correct |
17 |
Correct |
1 ms |
364 KB |
Output is correct |
18 |
Correct |
1 ms |
364 KB |
Output is correct |
19 |
Correct |
1 ms |
364 KB |
Output is correct |
20 |
Correct |
2 ms |
1004 KB |
Output is correct |
21 |
Correct |
2 ms |
620 KB |
Output is correct |
22 |
Correct |
2 ms |
1132 KB |
Output is correct |
23 |
Correct |
2 ms |
1388 KB |
Output is correct |
24 |
Correct |
2 ms |
1152 KB |
Output is correct |
25 |
Correct |
2 ms |
748 KB |
Output is correct |
26 |
Correct |
2 ms |
748 KB |
Output is correct |
27 |
Correct |
2 ms |
620 KB |
Output is correct |
28 |
Correct |
2 ms |
1004 KB |
Output is correct |
29 |
Correct |
3 ms |
1004 KB |
Output is correct |
30 |
Correct |
2 ms |
1388 KB |
Output is correct |
31 |
Correct |
86 ms |
16780 KB |
Output is correct |
32 |
Correct |
86 ms |
20844 KB |
Output is correct |
33 |
Correct |
100 ms |
37244 KB |
Output is correct |
34 |
Correct |
108 ms |
49644 KB |
Output is correct |
35 |
Correct |
111 ms |
53740 KB |
Output is correct |
36 |
Correct |
153 ms |
90652 KB |
Output is correct |
37 |
Correct |
79 ms |
16876 KB |
Output is correct |
38 |
Correct |
86 ms |
24940 KB |
Output is correct |
39 |
Execution timed out |
1091 ms |
41324 KB |
Time limit exceeded |
40 |
Halted |
0 ms |
0 KB |
- |