# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
171996 | 2019-12-30T18:39:24 Z | emil_physmath | Bank (IZhO14_bank) | C++17 | 1000 ms | 9368 KB |
#include <iostream> #include <vector> #include <set> using namespace std; typedef double ldouble; typedef long long llong; typedef unsigned int uint; const int maxN = 100001; vector<uint> sumup[1001]; bool IsSet(uint mask, uint i) { return mask & (1 << i); } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); int n, m; cin >> n >> m; vector<int> a(n); for (int& x: a) cin >> x; vector<int> b(m); for (int& x: b) cin >> x; for (uint mask = 0; mask < (1 << m); ++mask) { int curSum = 0; for (int i = 0; i < m; ++i) if (IsSet(mask, i)) curSum += b[i]; if (curSum <= 1000) sumup[curSum].push_back(mask); } vector<uint> possLeft; /* for (uint mask = 0; mask < (1 << m); ++mask) possLeft.push_back(mask); */ possLeft.push_back((1 << m) - 1); vector<uint> temp; for (int i = 0; i < n; ++i) { temp.clear(); // cerr << possLeft.size() << endl; for (uint left: possLeft) { for (uint mask: sumup[a[i]]) { // cerr << "get " << a[i] << " with " << mask << endl; if ((mask & left) == mask) temp.push_back(left ^ mask); } } possLeft.swap(temp); } // cerr << possLeft.size() << endl; cout << (possLeft.size() ? "YES" : "NO"); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
4 | Correct | 4 ms | 504 KB | Output is correct |
5 | Correct | 94 ms | 6576 KB | Output is correct |
6 | Correct | 2 ms | 376 KB | Output is correct |
7 | Correct | 2 ms | 376 KB | Output is correct |
8 | Correct | 93 ms | 5928 KB | Output is correct |
9 | Correct | 93 ms | 6256 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 380 KB | Output is correct |
4 | Correct | 2 ms | 376 KB | Output is correct |
5 | Correct | 2 ms | 376 KB | Output is correct |
6 | Correct | 2 ms | 376 KB | Output is correct |
7 | Correct | 2 ms | 376 KB | Output is correct |
8 | Correct | 2 ms | 376 KB | Output is correct |
9 | Correct | 2 ms | 376 KB | Output is correct |
10 | Correct | 2 ms | 376 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 376 KB | Output is correct |
2 | Correct | 3 ms | 376 KB | Output is correct |
3 | Correct | 3 ms | 376 KB | Output is correct |
4 | Correct | 3 ms | 504 KB | Output is correct |
5 | Correct | 3 ms | 508 KB | Output is correct |
6 | Correct | 3 ms | 376 KB | Output is correct |
7 | Correct | 3 ms | 376 KB | Output is correct |
8 | Correct | 3 ms | 376 KB | Output is correct |
9 | Correct | 3 ms | 376 KB | Output is correct |
10 | Correct | 3 ms | 376 KB | Output is correct |
11 | Correct | 3 ms | 376 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
4 | Correct | 4 ms | 504 KB | Output is correct |
5 | Correct | 94 ms | 6576 KB | Output is correct |
6 | Correct | 2 ms | 376 KB | Output is correct |
7 | Correct | 2 ms | 376 KB | Output is correct |
8 | Correct | 93 ms | 5928 KB | Output is correct |
9 | Correct | 93 ms | 6256 KB | Output is correct |
10 | Correct | 2 ms | 376 KB | Output is correct |
11 | Correct | 2 ms | 376 KB | Output is correct |
12 | Correct | 2 ms | 380 KB | Output is correct |
13 | Correct | 2 ms | 376 KB | Output is correct |
14 | Correct | 2 ms | 376 KB | Output is correct |
15 | Correct | 2 ms | 376 KB | Output is correct |
16 | Correct | 2 ms | 376 KB | Output is correct |
17 | Correct | 2 ms | 376 KB | Output is correct |
18 | Correct | 2 ms | 376 KB | Output is correct |
19 | Correct | 2 ms | 376 KB | Output is correct |
20 | Correct | 3 ms | 376 KB | Output is correct |
21 | Correct | 3 ms | 376 KB | Output is correct |
22 | Correct | 3 ms | 376 KB | Output is correct |
23 | Correct | 3 ms | 504 KB | Output is correct |
24 | Correct | 3 ms | 508 KB | Output is correct |
25 | Correct | 3 ms | 376 KB | Output is correct |
26 | Correct | 3 ms | 376 KB | Output is correct |
27 | Correct | 3 ms | 376 KB | Output is correct |
28 | Correct | 3 ms | 376 KB | Output is correct |
29 | Correct | 3 ms | 376 KB | Output is correct |
30 | Correct | 3 ms | 376 KB | Output is correct |
31 | Correct | 90 ms | 5624 KB | Output is correct |
32 | Execution timed out | 1048 ms | 9368 KB | Time limit exceeded |
33 | Halted | 0 ms | 0 KB | - |