# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
172001 | 2019-12-30T18:47:16 Z | emil_physmath | Bank (IZhO14_bank) | C++17 | 906 ms | 262148 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]; int sum[1 << 20], bits[1 << 20]; 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, curBits = 0; for (int i = 0; i < m; ++i) if (IsSet(mask, i)) { ++curBits; curSum += b[i]; } if (curSum <= 1000) sumup[curSum].push_back(mask); sum[mask] = curSum; bits[mask] = curBits; } 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) { if ((1 << bits[left]) < sumup[a[i]].size()) for(uint mask = left; mask; mask = (mask - 1) & left) { if (sum[mask] == a[i]) temp.push_back(mask); } else 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 | 5 ms | 760 KB | Output is correct |
5 | Correct | 101 ms | 14840 KB | Output is correct |
6 | Correct | 2 ms | 376 KB | Output is correct |
7 | Correct | 2 ms | 376 KB | Output is correct |
8 | Correct | 97 ms | 14200 KB | Output is correct |
9 | Correct | 98 ms | 14368 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 | 2 ms | 424 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 | 380 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 | 504 KB | Output is correct |
2 | Correct | 3 ms | 504 KB | Output is correct |
3 | Correct | 3 ms | 504 KB | Output is correct |
4 | Correct | 3 ms | 632 KB | Output is correct |
5 | Correct | 3 ms | 632 KB | Output is correct |
6 | Correct | 3 ms | 504 KB | Output is correct |
7 | Correct | 3 ms | 632 KB | Output is correct |
8 | Correct | 3 ms | 504 KB | Output is correct |
9 | Correct | 3 ms | 504 KB | Output is correct |
10 | Correct | 3 ms | 504 KB | Output is correct |
11 | Correct | 3 ms | 632 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 | 5 ms | 760 KB | Output is correct |
5 | Correct | 101 ms | 14840 KB | Output is correct |
6 | Correct | 2 ms | 376 KB | Output is correct |
7 | Correct | 2 ms | 376 KB | Output is correct |
8 | Correct | 97 ms | 14200 KB | Output is correct |
9 | Correct | 98 ms | 14368 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 | 376 KB | Output is correct |
13 | Correct | 2 ms | 424 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 | 380 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 | 504 KB | Output is correct |
21 | Correct | 3 ms | 504 KB | Output is correct |
22 | Correct | 3 ms | 504 KB | Output is correct |
23 | Correct | 3 ms | 632 KB | Output is correct |
24 | Correct | 3 ms | 632 KB | Output is correct |
25 | Correct | 3 ms | 504 KB | Output is correct |
26 | Correct | 3 ms | 632 KB | Output is correct |
27 | Correct | 3 ms | 504 KB | Output is correct |
28 | Correct | 3 ms | 504 KB | Output is correct |
29 | Correct | 3 ms | 504 KB | Output is correct |
30 | Correct | 3 ms | 632 KB | Output is correct |
31 | Correct | 96 ms | 13816 KB | Output is correct |
32 | Correct | 302 ms | 18448 KB | Output is correct |
33 | Correct | 86 ms | 9340 KB | Output is correct |
34 | Correct | 84 ms | 8760 KB | Output is correct |
35 | Correct | 84 ms | 8568 KB | Output is correct |
36 | Correct | 84 ms | 8568 KB | Output is correct |
37 | Correct | 85 ms | 8796 KB | Output is correct |
38 | Correct | 84 ms | 8700 KB | Output is correct |
39 | Runtime error | 906 ms | 262148 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
40 | Halted | 0 ms | 0 KB | - |