# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
173079 | 2020-01-03T10:18:14 Z | emil_physmath | 은행 (IZhO14_bank) | C++17 | 1000 ms | 79496 KB |
#include <algorithm> #include <iostream> #include <vector> #include <set> using namespace std; typedef double ldouble; typedef long long llong; typedef unsigned int uint; 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(left ^ 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
# | 결과 | 실행 시간 | 메모리 | 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 | 888 KB | Output is correct |
5 | Correct | 99 ms | 14788 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 | 14220 KB | Output is correct |
9 | Correct | 99 ms | 14456 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | 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 | 3 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 | 380 KB | Output is correct |
8 | Correct | 2 ms | 380 KB | Output is correct |
9 | Correct | 2 ms | 376 KB | Output is correct |
10 | Correct | 2 ms | 376 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 504 KB | Output is correct |
2 | Correct | 3 ms | 504 KB | Output is correct |
3 | Correct | 3 ms | 508 KB | Output is correct |
4 | Correct | 4 ms | 632 KB | Output is correct |
5 | Correct | 4 ms | 636 KB | Output is correct |
6 | Correct | 3 ms | 508 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 |
# | 결과 | 실행 시간 | 메모리 | 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 | 888 KB | Output is correct |
5 | Correct | 99 ms | 14788 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 | 14220 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 | 376 KB | Output is correct |
13 | Correct | 3 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 | 380 KB | Output is correct |
17 | Correct | 2 ms | 380 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 | 508 KB | Output is correct |
23 | Correct | 4 ms | 632 KB | Output is correct |
24 | Correct | 4 ms | 636 KB | Output is correct |
25 | Correct | 3 ms | 508 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 | 96 ms | 13784 KB | Output is correct |
32 | Correct | 146 ms | 16760 KB | Output is correct |
33 | Correct | 87 ms | 9276 KB | Output is correct |
34 | Correct | 85 ms | 8540 KB | Output is correct |
35 | Correct | 85 ms | 8568 KB | Output is correct |
36 | Correct | 85 ms | 8568 KB | Output is correct |
37 | Correct | 85 ms | 8864 KB | Output is correct |
38 | Correct | 86 ms | 8704 KB | Output is correct |
39 | Correct | 255 ms | 18124 KB | Output is correct |
40 | Correct | 88 ms | 10232 KB | Output is correct |
41 | Correct | 87 ms | 9096 KB | Output is correct |
42 | Correct | 105 ms | 14200 KB | Output is correct |
43 | Correct | 88 ms | 10236 KB | Output is correct |
44 | Correct | 85 ms | 8568 KB | Output is correct |
45 | Correct | 102 ms | 14712 KB | Output is correct |
46 | Correct | 91 ms | 11512 KB | Output is correct |
47 | Correct | 85 ms | 8568 KB | Output is correct |
48 | Correct | 101 ms | 14276 KB | Output is correct |
49 | Correct | 98 ms | 14456 KB | Output is correct |
50 | Correct | 871 ms | 22444 KB | Output is correct |
51 | Correct | 99 ms | 14072 KB | Output is correct |
52 | Correct | 106 ms | 13588 KB | Output is correct |
53 | Execution timed out | 1084 ms | 79496 KB | Time limit exceeded |
54 | Halted | 0 ms | 0 KB | - |