# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
250394 |
2020-07-17T16:41:31 Z |
srvlt |
Bank (IZhO14_bank) |
C++14 |
|
202 ms |
4608 KB |
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define ld long double
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define SZ(x) (int)(x).size()
template <typename T> using ord_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int n, m, a[20], b[20], dp[1 << 20];
int main() {
ios_base::sync_with_stdio(false), cin.tie(NULL);
#ifdef LOCAL
freopen("input.txt", "r", stdin);
#endif
memset(& dp, -1, sizeof(dp));
cin >> n >> m;
for (int i = 0; i < n; i++) cin >> a[i];
for (int i = 0; i < m; i++) cin >> b[i];
dp[0] = 0;
int cur = 0;
for (int i = 0; i < n; i++) {
for (int j = 0; j < (1 << m); j++) {
if (dp[j] >= cur) {
for (int k = 0; k < m; k++) {
if (j >> k & 1) continue;
if (dp[j] + b[k] <= cur + a[i])
dp[j ^ (1 << k)] = dp[j] + b[k];
}
}
}
cur += a[i];
}
for (int i = 0; i < (1 << m); i++)
if (dp[i] == cur) return cout << "YES", 0;
cout << "NO";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
4480 KB |
Output is correct |
2 |
Correct |
2 ms |
4480 KB |
Output is correct |
3 |
Correct |
3 ms |
4480 KB |
Output is correct |
4 |
Correct |
3 ms |
4480 KB |
Output is correct |
5 |
Correct |
4 ms |
4480 KB |
Output is correct |
6 |
Correct |
2 ms |
4480 KB |
Output is correct |
7 |
Correct |
3 ms |
4480 KB |
Output is correct |
8 |
Correct |
47 ms |
4600 KB |
Output is correct |
9 |
Correct |
78 ms |
4480 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
4480 KB |
Output is correct |
2 |
Correct |
4 ms |
4480 KB |
Output is correct |
3 |
Correct |
3 ms |
4480 KB |
Output is correct |
4 |
Correct |
3 ms |
4480 KB |
Output is correct |
5 |
Correct |
3 ms |
4480 KB |
Output is correct |
6 |
Correct |
3 ms |
4480 KB |
Output is correct |
7 |
Correct |
3 ms |
4480 KB |
Output is correct |
8 |
Correct |
4 ms |
4480 KB |
Output is correct |
9 |
Correct |
3 ms |
4480 KB |
Output is correct |
10 |
Correct |
3 ms |
4480 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
4480 KB |
Output is correct |
2 |
Correct |
3 ms |
4480 KB |
Output is correct |
3 |
Correct |
3 ms |
4480 KB |
Output is correct |
4 |
Correct |
3 ms |
4480 KB |
Output is correct |
5 |
Correct |
3 ms |
4480 KB |
Output is correct |
6 |
Correct |
4 ms |
4480 KB |
Output is correct |
7 |
Correct |
3 ms |
4480 KB |
Output is correct |
8 |
Correct |
3 ms |
4480 KB |
Output is correct |
9 |
Correct |
3 ms |
4480 KB |
Output is correct |
10 |
Correct |
3 ms |
4480 KB |
Output is correct |
11 |
Correct |
5 ms |
4480 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
4480 KB |
Output is correct |
2 |
Correct |
2 ms |
4480 KB |
Output is correct |
3 |
Correct |
3 ms |
4480 KB |
Output is correct |
4 |
Correct |
3 ms |
4480 KB |
Output is correct |
5 |
Correct |
4 ms |
4480 KB |
Output is correct |
6 |
Correct |
2 ms |
4480 KB |
Output is correct |
7 |
Correct |
3 ms |
4480 KB |
Output is correct |
8 |
Correct |
47 ms |
4600 KB |
Output is correct |
9 |
Correct |
78 ms |
4480 KB |
Output is correct |
10 |
Correct |
3 ms |
4480 KB |
Output is correct |
11 |
Correct |
4 ms |
4480 KB |
Output is correct |
12 |
Correct |
3 ms |
4480 KB |
Output is correct |
13 |
Correct |
3 ms |
4480 KB |
Output is correct |
14 |
Correct |
3 ms |
4480 KB |
Output is correct |
15 |
Correct |
3 ms |
4480 KB |
Output is correct |
16 |
Correct |
3 ms |
4480 KB |
Output is correct |
17 |
Correct |
4 ms |
4480 KB |
Output is correct |
18 |
Correct |
3 ms |
4480 KB |
Output is correct |
19 |
Correct |
3 ms |
4480 KB |
Output is correct |
20 |
Correct |
3 ms |
4480 KB |
Output is correct |
21 |
Correct |
3 ms |
4480 KB |
Output is correct |
22 |
Correct |
3 ms |
4480 KB |
Output is correct |
23 |
Correct |
3 ms |
4480 KB |
Output is correct |
24 |
Correct |
3 ms |
4480 KB |
Output is correct |
25 |
Correct |
4 ms |
4480 KB |
Output is correct |
26 |
Correct |
3 ms |
4480 KB |
Output is correct |
27 |
Correct |
3 ms |
4480 KB |
Output is correct |
28 |
Correct |
3 ms |
4480 KB |
Output is correct |
29 |
Correct |
3 ms |
4480 KB |
Output is correct |
30 |
Correct |
5 ms |
4480 KB |
Output is correct |
31 |
Correct |
70 ms |
4492 KB |
Output is correct |
32 |
Correct |
88 ms |
4480 KB |
Output is correct |
33 |
Correct |
16 ms |
4480 KB |
Output is correct |
34 |
Correct |
12 ms |
4480 KB |
Output is correct |
35 |
Correct |
16 ms |
4480 KB |
Output is correct |
36 |
Correct |
20 ms |
4480 KB |
Output is correct |
37 |
Correct |
5 ms |
4480 KB |
Output is correct |
38 |
Correct |
7 ms |
4480 KB |
Output is correct |
39 |
Correct |
43 ms |
4480 KB |
Output is correct |
40 |
Correct |
13 ms |
4480 KB |
Output is correct |
41 |
Correct |
22 ms |
4480 KB |
Output is correct |
42 |
Correct |
59 ms |
4600 KB |
Output is correct |
43 |
Correct |
12 ms |
4480 KB |
Output is correct |
44 |
Correct |
17 ms |
4480 KB |
Output is correct |
45 |
Correct |
48 ms |
4480 KB |
Output is correct |
46 |
Correct |
30 ms |
4480 KB |
Output is correct |
47 |
Correct |
17 ms |
4480 KB |
Output is correct |
48 |
Correct |
19 ms |
4608 KB |
Output is correct |
49 |
Correct |
4 ms |
4480 KB |
Output is correct |
50 |
Correct |
185 ms |
4496 KB |
Output is correct |
51 |
Correct |
14 ms |
4480 KB |
Output is correct |
52 |
Correct |
17 ms |
4500 KB |
Output is correct |
53 |
Correct |
130 ms |
4496 KB |
Output is correct |
54 |
Correct |
172 ms |
4480 KB |
Output is correct |
55 |
Correct |
186 ms |
4480 KB |
Output is correct |
56 |
Correct |
194 ms |
4600 KB |
Output is correct |
57 |
Correct |
194 ms |
4496 KB |
Output is correct |
58 |
Correct |
202 ms |
4488 KB |
Output is correct |