Submission #707020

# Submission time Handle Problem Language Result Execution time Memory
707020 2023-03-08T09:55:13 Z VladPislaru Bank (IZhO14_bank) C++17
71 / 100
1000 ms 19804 KB
#include <bits/stdc++.h>

using namespace std;


int n, m;
int a[1005], b[1005];
int sum[(1 << 20) + 5], nr_bit[(1 << 20) + 5];

unordered_set <int> poss[1005], sol;

int main()
{
    cin >> n >> m;
    for (int i = 0; i < n; i++)
        cin >> a[i];
    for (int i = 0; i < m; i++)
        cin >> b[i];
    for (int j = 0; j < (1 << m); j++) {
        for (int k = 0; k < m; k++)
            if (j & (1 << k)) {
                sum[j] += b[k];
                nr_bit[j]++;
            }

    }
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < (1 << m); j++) {
            if (sum[j] == a[i])
                poss[i].insert(j);
        }
    }

    for (int j : poss[0])
        sol.insert(j);

    for (int i = 1; i < n; i++) {
        unordered_set <int> aux;
        for (int j : poss[i])
            for (int k : sol)
                if (nr_bit[j] + nr_bit[k] == nr_bit[j | k])
                    aux.insert(j | k);
        sol = aux;
    }
    if (sol.size())
        cout << "YES\n";
    else cout << "NO\n";

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 3 ms 596 KB Output is correct
5 Correct 66 ms 8488 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 68 ms 9076 KB Output is correct
9 Correct 66 ms 8540 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 360 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 364 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 468 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 0 ms 360 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 468 KB Output is correct
2 Correct 2 ms 468 KB Output is correct
3 Correct 2 ms 468 KB Output is correct
4 Correct 2 ms 468 KB Output is correct
5 Correct 2 ms 468 KB Output is correct
6 Correct 2 ms 468 KB Output is correct
7 Correct 2 ms 468 KB Output is correct
8 Correct 1 ms 468 KB Output is correct
9 Correct 2 ms 488 KB Output is correct
10 Correct 2 ms 468 KB Output is correct
11 Correct 2 ms 468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 3 ms 596 KB Output is correct
5 Correct 66 ms 8488 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 68 ms 9076 KB Output is correct
9 Correct 66 ms 8540 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 360 KB Output is correct
13 Correct 0 ms 340 KB Output is correct
14 Correct 0 ms 364 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 468 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 0 ms 360 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 2 ms 468 KB Output is correct
21 Correct 2 ms 468 KB Output is correct
22 Correct 2 ms 468 KB Output is correct
23 Correct 2 ms 468 KB Output is correct
24 Correct 2 ms 468 KB Output is correct
25 Correct 2 ms 468 KB Output is correct
26 Correct 2 ms 468 KB Output is correct
27 Correct 1 ms 468 KB Output is correct
28 Correct 2 ms 488 KB Output is correct
29 Correct 2 ms 468 KB Output is correct
30 Correct 2 ms 468 KB Output is correct
31 Correct 73 ms 8680 KB Output is correct
32 Correct 436 ms 10060 KB Output is correct
33 Correct 84 ms 8552 KB Output is correct
34 Correct 90 ms 8500 KB Output is correct
35 Correct 95 ms 8532 KB Output is correct
36 Correct 119 ms 8672 KB Output is correct
37 Correct 69 ms 8456 KB Output is correct
38 Correct 75 ms 8544 KB Output is correct
39 Correct 181 ms 19784 KB Output is correct
40 Correct 91 ms 8556 KB Output is correct
41 Correct 117 ms 8548 KB Output is correct
42 Correct 93 ms 8952 KB Output is correct
43 Correct 84 ms 8496 KB Output is correct
44 Correct 115 ms 8436 KB Output is correct
45 Correct 84 ms 8784 KB Output is correct
46 Correct 81 ms 8644 KB Output is correct
47 Correct 105 ms 8556 KB Output is correct
48 Correct 66 ms 8848 KB Output is correct
49 Correct 65 ms 8540 KB Output is correct
50 Correct 666 ms 19804 KB Output is correct
51 Correct 95 ms 9004 KB Output is correct
52 Correct 104 ms 8780 KB Output is correct
53 Execution timed out 1073 ms 18212 KB Time limit exceeded
54 Halted 0 ms 0 KB -