# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
100478 |
2019-03-11T14:42:36 Z |
RockyB |
Bank (IZhO14_bank) |
C++17 |
|
1000 ms |
86648 KB |
/// In The Name Of God
#include <bits/stdc++.h>
#define f first
#define s second
#define pb push_back
#define pp pop_back
#define mp make_pair
#define sz(x) (int)x.size()
#define sqr(x) ((x) * 1ll * (x))
#define all(x) x.begin(), x.end()
#define rep(i, l, r) for (int i = (l); i < (r); i++)
#define per(i, l, r) for (int i = (l); i >= (r); i--)
#define Kazakhstan ios_base :: sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define nl '\n'
#define ioi exit(0);
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
const int N = (int)5e5 + 7;
const int inf = (int)1e9 + 7;
const int mod = (int)1e9 + 7;
const ll linf = (ll)1e18 + 7;
const int dx[] = {-1, 0, 1, 0, 1, -1, -1, 1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
using namespace std;
int n, m;
int a[N], b[N];
int sum[1 << 20];
int dp[20][1 << 20];
int calc(int v = 0, int mask = (1 << m) - 1) {
if (v == n) return 1;
if (~dp[v][mask]) return dp[v][mask];
int res = 0;
for (int j = mask; !res;j = mask & (j - 1)) {
if (!j) break;
if (a[v] == sum[j]) {
res |= calc(v + 1, mask ^ j);
}
}
return dp[v][mask] = res;
}
int main() {
#ifdef IOI2018
freopen ("in.txt", "r", stdin);
#endif
Kazakhstan
cin >> n >> m;
rep(i, 0, n) cin >> a[i];
rep(i, 0, m) cin >> b[i];
rep(mask, 0, (1 << m)) {
rep(i, 0, m) {
if (mask & (1 << i)) sum[mask] += b[i];
}
}
memset(dp, -1, sizeof(dp));
if (calc()) cout << "YES";
else cout << "NO";
ioi
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
71 ms |
82424 KB |
Output is correct |
2 |
Correct |
70 ms |
82424 KB |
Output is correct |
3 |
Correct |
76 ms |
82524 KB |
Output is correct |
4 |
Correct |
70 ms |
82552 KB |
Output is correct |
5 |
Correct |
136 ms |
86528 KB |
Output is correct |
6 |
Correct |
67 ms |
82424 KB |
Output is correct |
7 |
Correct |
67 ms |
82552 KB |
Output is correct |
8 |
Correct |
136 ms |
86536 KB |
Output is correct |
9 |
Correct |
134 ms |
86520 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
67 ms |
82424 KB |
Output is correct |
2 |
Correct |
71 ms |
82448 KB |
Output is correct |
3 |
Correct |
68 ms |
82424 KB |
Output is correct |
4 |
Correct |
75 ms |
82448 KB |
Output is correct |
5 |
Correct |
76 ms |
82424 KB |
Output is correct |
6 |
Correct |
66 ms |
82408 KB |
Output is correct |
7 |
Correct |
70 ms |
82412 KB |
Output is correct |
8 |
Correct |
71 ms |
82552 KB |
Output is correct |
9 |
Correct |
76 ms |
82500 KB |
Output is correct |
10 |
Correct |
68 ms |
82428 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
68 ms |
82424 KB |
Output is correct |
2 |
Correct |
71 ms |
82524 KB |
Output is correct |
3 |
Correct |
70 ms |
82556 KB |
Output is correct |
4 |
Correct |
69 ms |
82552 KB |
Output is correct |
5 |
Correct |
78 ms |
82424 KB |
Output is correct |
6 |
Correct |
71 ms |
82424 KB |
Output is correct |
7 |
Correct |
75 ms |
82680 KB |
Output is correct |
8 |
Correct |
67 ms |
82424 KB |
Output is correct |
9 |
Correct |
67 ms |
82552 KB |
Output is correct |
10 |
Correct |
68 ms |
82552 KB |
Output is correct |
11 |
Correct |
69 ms |
82484 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
71 ms |
82424 KB |
Output is correct |
2 |
Correct |
70 ms |
82424 KB |
Output is correct |
3 |
Correct |
76 ms |
82524 KB |
Output is correct |
4 |
Correct |
70 ms |
82552 KB |
Output is correct |
5 |
Correct |
136 ms |
86528 KB |
Output is correct |
6 |
Correct |
67 ms |
82424 KB |
Output is correct |
7 |
Correct |
67 ms |
82552 KB |
Output is correct |
8 |
Correct |
136 ms |
86536 KB |
Output is correct |
9 |
Correct |
134 ms |
86520 KB |
Output is correct |
10 |
Correct |
67 ms |
82424 KB |
Output is correct |
11 |
Correct |
71 ms |
82448 KB |
Output is correct |
12 |
Correct |
68 ms |
82424 KB |
Output is correct |
13 |
Correct |
75 ms |
82448 KB |
Output is correct |
14 |
Correct |
76 ms |
82424 KB |
Output is correct |
15 |
Correct |
66 ms |
82408 KB |
Output is correct |
16 |
Correct |
70 ms |
82412 KB |
Output is correct |
17 |
Correct |
71 ms |
82552 KB |
Output is correct |
18 |
Correct |
76 ms |
82500 KB |
Output is correct |
19 |
Correct |
68 ms |
82428 KB |
Output is correct |
20 |
Correct |
68 ms |
82424 KB |
Output is correct |
21 |
Correct |
71 ms |
82524 KB |
Output is correct |
22 |
Correct |
70 ms |
82556 KB |
Output is correct |
23 |
Correct |
69 ms |
82552 KB |
Output is correct |
24 |
Correct |
78 ms |
82424 KB |
Output is correct |
25 |
Correct |
71 ms |
82424 KB |
Output is correct |
26 |
Correct |
75 ms |
82680 KB |
Output is correct |
27 |
Correct |
67 ms |
82424 KB |
Output is correct |
28 |
Correct |
67 ms |
82552 KB |
Output is correct |
29 |
Correct |
68 ms |
82552 KB |
Output is correct |
30 |
Correct |
69 ms |
82484 KB |
Output is correct |
31 |
Correct |
150 ms |
86488 KB |
Output is correct |
32 |
Correct |
132 ms |
86580 KB |
Output is correct |
33 |
Correct |
140 ms |
86520 KB |
Output is correct |
34 |
Correct |
152 ms |
86536 KB |
Output is correct |
35 |
Correct |
140 ms |
86576 KB |
Output is correct |
36 |
Correct |
140 ms |
86456 KB |
Output is correct |
37 |
Correct |
140 ms |
86648 KB |
Output is correct |
38 |
Correct |
141 ms |
86596 KB |
Output is correct |
39 |
Correct |
135 ms |
86492 KB |
Output is correct |
40 |
Correct |
147 ms |
86496 KB |
Output is correct |
41 |
Correct |
137 ms |
86520 KB |
Output is correct |
42 |
Correct |
160 ms |
86520 KB |
Output is correct |
43 |
Correct |
166 ms |
86520 KB |
Output is correct |
44 |
Correct |
146 ms |
86520 KB |
Output is correct |
45 |
Correct |
140 ms |
86624 KB |
Output is correct |
46 |
Correct |
138 ms |
86492 KB |
Output is correct |
47 |
Correct |
135 ms |
86520 KB |
Output is correct |
48 |
Correct |
140 ms |
86520 KB |
Output is correct |
49 |
Correct |
144 ms |
86636 KB |
Output is correct |
50 |
Execution timed out |
1095 ms |
86548 KB |
Time limit exceeded |
51 |
Halted |
0 ms |
0 KB |
- |