# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
173076 | 2020-01-03T10:13:35 Z | emil_physmath | Bank (IZhO14_bank) | C++17 | 867 ms | 22516 KB |
#include <algorithm> #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.clear(); sort(temp.begin(), temp.end()); for (int i = 0; i < temp.size(); ++i) if (!i || temp[i] != temp[i - 1]) possLeft.push_back(temp[i]); } // 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 | 99 ms | 14732 KB | Output is correct |
6 | Correct | 2 ms | 376 KB | Output is correct |
7 | Correct | 2 ms | 376 KB | Output is correct |
8 | Correct | 98 ms | 14192 KB | Output is correct |
9 | Correct | 99 ms | 14456 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 | 504 KB | Output is correct |
2 | Correct | 3 ms | 504 KB | Output is correct |
3 | Correct | 4 ms | 504 KB | Output is correct |
4 | Correct | 4 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 | 504 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 | 504 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 | 99 ms | 14732 KB | Output is correct |
6 | Correct | 2 ms | 376 KB | Output is correct |
7 | Correct | 2 ms | 376 KB | Output is correct |
8 | Correct | 98 ms | 14192 KB | Output is correct |
9 | Correct | 99 ms | 14456 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 | 504 KB | Output is correct |
21 | Correct | 3 ms | 504 KB | Output is correct |
22 | Correct | 4 ms | 504 KB | Output is correct |
23 | Correct | 4 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 | 504 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 | 504 KB | Output is correct |
31 | Correct | 97 ms | 13916 KB | Output is correct |
32 | Correct | 181 ms | 16784 KB | Output is correct |
33 | Correct | 86 ms | 9340 KB | Output is correct |
34 | Correct | 85 ms | 8644 KB | Output is correct |
35 | Correct | 86 ms | 8596 KB | Output is correct |
36 | Correct | 85 ms | 8568 KB | Output is correct |
37 | Correct | 85 ms | 8696 KB | Output is correct |
38 | Correct | 86 ms | 8680 KB | Output is correct |
39 | Correct | 256 ms | 18252 KB | Output is correct |
40 | Correct | 88 ms | 10232 KB | Output is correct |
41 | Correct | 86 ms | 9104 KB | Output is correct |
42 | Correct | 107 ms | 14200 KB | Output is correct |
43 | Correct | 88 ms | 10232 KB | Output is correct |
44 | Correct | 88 ms | 8584 KB | Output is correct |
45 | Correct | 102 ms | 14696 KB | Output is correct |
46 | Correct | 91 ms | 11544 KB | Output is correct |
47 | Correct | 85 ms | 8568 KB | Output is correct |
48 | Correct | 99 ms | 14328 KB | Output is correct |
49 | Correct | 98 ms | 14368 KB | Output is correct |
50 | Correct | 867 ms | 22516 KB | Output is correct |
51 | Incorrect | 100 ms | 14188 KB | Output isn't correct |
52 | Halted | 0 ms | 0 KB | - |