Submission #171994

# Submission time Handle Problem Language Result Execution time Memory
171994 2019-12-30T18:33:57 Z emil_physmath Bank (IZhO14_bank) C++17
71 / 100
1000 ms 17472 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);
    }
    set<uint> possLeft;
    /* for (uint mask = 0; mask < (1 << m); ++mask)
        possLeft.insert(mask); */
    possLeft.insert((1 << m) - 1);
    for (int i = 0; i < n; ++i)
    {
        // cerr << possLeft.size() << endl;
        set<uint> temp;
        for (uint left: possLeft)
        {
            for (uint mask: sumup[a[i]])
            {
                // cerr << "get " << a[i] << " with " << mask << endl;
                if ((mask & left) == mask)
                    temp.insert(left ^ mask);
            }
        }
        possLeft.swap(temp);
    }
    // cerr << possLeft.size() << endl;
    cout << (possLeft.size() ? "YES" : "NO");
}

Compilation message

bank.cpp: In function 'int main()':
bank.cpp:30:30: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (uint mask = 0; mask < (1 << m); ++mask)
                         ~~~~~^~~~~~~~~~
# 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 4 ms 504 KB Output is correct
5 Correct 93 ms 6596 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 92 ms 6008 KB Output is correct
9 Correct 93 ms 6260 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 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 508 KB Output is correct
5 Correct 3 ms 504 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 380 KB Output is correct
10 Correct 3 ms 376 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 380 KB Output is correct
4 Correct 4 ms 504 KB Output is correct
5 Correct 93 ms 6596 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 92 ms 6008 KB Output is correct
9 Correct 93 ms 6260 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 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 508 KB Output is correct
24 Correct 3 ms 504 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 380 KB Output is correct
29 Correct 3 ms 376 KB Output is correct
30 Correct 3 ms 504 KB Output is correct
31 Correct 90 ms 5752 KB Output is correct
32 Correct 181 ms 6168 KB Output is correct
33 Correct 82 ms 1016 KB Output is correct
34 Correct 80 ms 376 KB Output is correct
35 Correct 80 ms 376 KB Output is correct
36 Correct 80 ms 376 KB Output is correct
37 Correct 82 ms 556 KB Output is correct
38 Correct 88 ms 504 KB Output is correct
39 Correct 312 ms 14332 KB Output is correct
40 Correct 83 ms 2040 KB Output is correct
41 Correct 83 ms 888 KB Output is correct
42 Correct 100 ms 5752 KB Output is correct
43 Correct 82 ms 2168 KB Output is correct
44 Correct 80 ms 504 KB Output is correct
45 Correct 97 ms 6392 KB Output is correct
46 Correct 86 ms 3320 KB Output is correct
47 Correct 80 ms 504 KB Output is correct
48 Correct 93 ms 6012 KB Output is correct
49 Correct 92 ms 6264 KB Output is correct
50 Execution timed out 1070 ms 17472 KB Time limit exceeded
51 Halted 0 ms 0 KB -