# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
171454 |
2019-12-28T16:53:04 Z |
ne4eHbKa |
Bank (IZhO14_bank) |
C++17 |
|
1000 ms |
22040 KB |
//{ <defines>
#ifndef _LOCAL
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("-O3")
#pragma GCC optimize("Ofast")
#endif
#include <bits/stdc++.h>
using namespace std;
#define fr(i, n) for(int i = 0; i < (n); ++i)
#define fo(n) fr(i, (n))
#define re return
#define ef else if
#define ifn(x) if(!(x))
#define _ << ' ' <<
#define ft first
#define sd second
#define ve vector
#define pb push_back
#define eb emplace_back
#define sz(x) int(x.size())
#define pw(x) (1 << (x))
#define PW(x) (1ll << (x))
#define bnd(x) x.begin(), x.end()
#define clr(x, y) memset(x, y, sizeof x)
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef ve<int> vi;
const int oo = 2e9;
const ll OO = 4e18;
//const ld pi = arg(complex<ld>(-1, 0));
//const ld pi2 = pi + pi;
const int md = 0x3b800001;
const int MD = 1e9 + 7;
inline ll time() {re chrono :: system_clock().now().time_since_epoch().count();}
mt19937 rnd(time());
mt19937_64 RND(time());
template<typename t> inline void umin(t &a, t b) {a = min(a, b);}
template<typename t> inline void umax(t &a, t b) {a = max(a, b);}
//} </defines>
const int N = 20;
const int M = 1 << N;
int n, m, a[N], b[N], s[M];
vi f[(int)2e4 + 5];
void solve() {
cin >> n >> m;
fo(n) cin >> a[i];
// random_shuffle(a, a + n, [](int x){re rnd() % x;});
fo(m) cin >> b[i];
sort(b, b + m);
#ifdef _LOCAL
for(auto &p : f) p.clear();
#endif
fo(1 << m) {
fr(j, m) ifn(i & pw(j)) s[i ^ pw(j)] = s[i] + b[j];
f[s[i]].pb(i);
}
set<int> G, H; set<int> *g = &G, *h = &H;
g -> insert(0);
fo(n) {
if(g -> empty() || f[a[i]].empty()) re void(cout << "NO\n");
h -> clear();
for(int t : *g) for(int j : f[a[i]]) ifn(j & t) h -> insert(j ^ t);
swap(g, h);
}
cout << (g -> empty() ? "NO\n" : "YES\n");
}
int main() {
#ifdef _LOCAL
freopen("in.txt", "r", stdin);
int tests; cin >> tests;
fo(tests) {
cerr << "case #" << i+1 << endl;
solve();
}
#else
ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
solve();
#endif
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
888 KB |
Output is correct |
2 |
Correct |
3 ms |
1016 KB |
Output is correct |
3 |
Correct |
3 ms |
888 KB |
Output is correct |
4 |
Correct |
5 ms |
1144 KB |
Output is correct |
5 |
Correct |
121 ms |
10940 KB |
Output is correct |
6 |
Correct |
3 ms |
888 KB |
Output is correct |
7 |
Correct |
3 ms |
888 KB |
Output is correct |
8 |
Correct |
127 ms |
10544 KB |
Output is correct |
9 |
Correct |
114 ms |
10360 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
888 KB |
Output is correct |
2 |
Correct |
2 ms |
888 KB |
Output is correct |
3 |
Correct |
3 ms |
888 KB |
Output is correct |
4 |
Correct |
2 ms |
764 KB |
Output is correct |
5 |
Correct |
3 ms |
760 KB |
Output is correct |
6 |
Correct |
3 ms |
888 KB |
Output is correct |
7 |
Correct |
2 ms |
760 KB |
Output is correct |
8 |
Correct |
3 ms |
760 KB |
Output is correct |
9 |
Correct |
3 ms |
888 KB |
Output is correct |
10 |
Correct |
3 ms |
888 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
1016 KB |
Output is correct |
2 |
Correct |
5 ms |
1016 KB |
Output is correct |
3 |
Correct |
5 ms |
1148 KB |
Output is correct |
4 |
Correct |
4 ms |
1016 KB |
Output is correct |
5 |
Correct |
5 ms |
1016 KB |
Output is correct |
6 |
Correct |
5 ms |
1144 KB |
Output is correct |
7 |
Correct |
4 ms |
1016 KB |
Output is correct |
8 |
Correct |
4 ms |
1016 KB |
Output is correct |
9 |
Correct |
4 ms |
1016 KB |
Output is correct |
10 |
Correct |
5 ms |
1016 KB |
Output is correct |
11 |
Correct |
4 ms |
1016 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
888 KB |
Output is correct |
2 |
Correct |
3 ms |
1016 KB |
Output is correct |
3 |
Correct |
3 ms |
888 KB |
Output is correct |
4 |
Correct |
5 ms |
1144 KB |
Output is correct |
5 |
Correct |
121 ms |
10940 KB |
Output is correct |
6 |
Correct |
3 ms |
888 KB |
Output is correct |
7 |
Correct |
3 ms |
888 KB |
Output is correct |
8 |
Correct |
127 ms |
10544 KB |
Output is correct |
9 |
Correct |
114 ms |
10360 KB |
Output is correct |
10 |
Correct |
3 ms |
888 KB |
Output is correct |
11 |
Correct |
2 ms |
888 KB |
Output is correct |
12 |
Correct |
3 ms |
888 KB |
Output is correct |
13 |
Correct |
2 ms |
764 KB |
Output is correct |
14 |
Correct |
3 ms |
760 KB |
Output is correct |
15 |
Correct |
3 ms |
888 KB |
Output is correct |
16 |
Correct |
2 ms |
760 KB |
Output is correct |
17 |
Correct |
3 ms |
760 KB |
Output is correct |
18 |
Correct |
3 ms |
888 KB |
Output is correct |
19 |
Correct |
3 ms |
888 KB |
Output is correct |
20 |
Correct |
5 ms |
1016 KB |
Output is correct |
21 |
Correct |
5 ms |
1016 KB |
Output is correct |
22 |
Correct |
5 ms |
1148 KB |
Output is correct |
23 |
Correct |
4 ms |
1016 KB |
Output is correct |
24 |
Correct |
5 ms |
1016 KB |
Output is correct |
25 |
Correct |
5 ms |
1144 KB |
Output is correct |
26 |
Correct |
4 ms |
1016 KB |
Output is correct |
27 |
Correct |
4 ms |
1016 KB |
Output is correct |
28 |
Correct |
4 ms |
1016 KB |
Output is correct |
29 |
Correct |
5 ms |
1016 KB |
Output is correct |
30 |
Correct |
4 ms |
1016 KB |
Output is correct |
31 |
Correct |
116 ms |
11124 KB |
Output is correct |
32 |
Correct |
177 ms |
10644 KB |
Output is correct |
33 |
Correct |
116 ms |
10372 KB |
Output is correct |
34 |
Correct |
127 ms |
10964 KB |
Output is correct |
35 |
Correct |
124 ms |
11384 KB |
Output is correct |
36 |
Correct |
125 ms |
11128 KB |
Output is correct |
37 |
Correct |
121 ms |
11304 KB |
Output is correct |
38 |
Correct |
120 ms |
11408 KB |
Output is correct |
39 |
Correct |
367 ms |
18856 KB |
Output is correct |
40 |
Correct |
117 ms |
11384 KB |
Output is correct |
41 |
Correct |
117 ms |
10588 KB |
Output is correct |
42 |
Correct |
119 ms |
10204 KB |
Output is correct |
43 |
Correct |
116 ms |
11324 KB |
Output is correct |
44 |
Correct |
131 ms |
11768 KB |
Output is correct |
45 |
Correct |
117 ms |
10704 KB |
Output is correct |
46 |
Correct |
116 ms |
11384 KB |
Output is correct |
47 |
Correct |
125 ms |
11000 KB |
Output is correct |
48 |
Correct |
114 ms |
10432 KB |
Output is correct |
49 |
Correct |
112 ms |
10492 KB |
Output is correct |
50 |
Execution timed out |
1075 ms |
22040 KB |
Time limit exceeded |
51 |
Halted |
0 ms |
0 KB |
- |