Submission #330704

# Submission time Handle Problem Language Result Execution time Memory
330704 2020-11-26T09:46:52 Z hakanai Bank (IZhO14_bank) C++17
100 / 100
539 ms 8684 KB
// https://oj.uz/problem/view/IZhO14_bank

#include <bits/stdc++.h>

using namespace std;

vector<int> mp[1005];
bool used1[1<<20], used2[1<<20];
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    vector<int> a(n), b(m);
    for ( int i=0; i<n; i++ ) cin >> a[i];
    for ( int i=0; i<m; i++ ) cin >> b[i];
    for ( int s=1; s<1<<m; s++ ) {
        int res = 0;
        for ( int i=0; i<m; i++ ) {
            if ( s>>i&1 ) res += b[i]; 
        }
        if ( res<1005 ) mp[res].push_back(s); 
    }
    used1[0] = 1;
    for ( int i=0; i<n; i++ ) {
        bool b = false;
        memset(used2, 0, sizeof(used2));
        for ( int s=0; s<1<<m; s++ ) {
            if ( !used1[s] ) continue;
            for ( int t:mp[a[i]] ) {
                if ( (s&t)==0 ) {
                    used2[s|t] = 1;
                    b = true;
                }
            }
        }
        if ( !b ) {
            cout << "NO" << '\n';
            return 0;
        }
        swap(used1, used2);
    }
    cout << "YES" << '\n';
    return 0;
}















# Verdict Execution time Memory Grader output
1 Correct 3 ms 2412 KB Output is correct
2 Correct 1 ms 1388 KB Output is correct
3 Correct 3 ms 2412 KB Output is correct
4 Correct 7 ms 2552 KB Output is correct
5 Correct 77 ms 7788 KB Output is correct
6 Correct 1 ms 1388 KB Output is correct
7 Correct 3 ms 2412 KB Output is correct
8 Correct 77 ms 7916 KB Output is correct
9 Correct 76 ms 7404 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 10 ms 2412 KB Output is correct
2 Correct 7 ms 2412 KB Output is correct
3 Correct 5 ms 2412 KB Output is correct
4 Correct 7 ms 2412 KB Output is correct
5 Correct 9 ms 2412 KB Output is correct
6 Correct 11 ms 2412 KB Output is correct
7 Correct 8 ms 2540 KB Output is correct
8 Correct 8 ms 2540 KB Output is correct
9 Correct 4 ms 2412 KB Output is correct
10 Correct 11 ms 2412 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 15 ms 2412 KB Output is correct
2 Correct 10 ms 2412 KB Output is correct
3 Correct 22 ms 2412 KB Output is correct
4 Correct 2 ms 1516 KB Output is correct
5 Correct 7 ms 2540 KB Output is correct
6 Correct 2 ms 1388 KB Output is correct
7 Correct 10 ms 2412 KB Output is correct
8 Correct 8 ms 2412 KB Output is correct
9 Correct 17 ms 2412 KB Output is correct
10 Correct 18 ms 2412 KB Output is correct
11 Correct 2 ms 1516 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 2412 KB Output is correct
2 Correct 1 ms 1388 KB Output is correct
3 Correct 3 ms 2412 KB Output is correct
4 Correct 7 ms 2552 KB Output is correct
5 Correct 77 ms 7788 KB Output is correct
6 Correct 1 ms 1388 KB Output is correct
7 Correct 3 ms 2412 KB Output is correct
8 Correct 77 ms 7916 KB Output is correct
9 Correct 76 ms 7404 KB Output is correct
10 Correct 10 ms 2412 KB Output is correct
11 Correct 7 ms 2412 KB Output is correct
12 Correct 5 ms 2412 KB Output is correct
13 Correct 7 ms 2412 KB Output is correct
14 Correct 9 ms 2412 KB Output is correct
15 Correct 11 ms 2412 KB Output is correct
16 Correct 8 ms 2540 KB Output is correct
17 Correct 8 ms 2540 KB Output is correct
18 Correct 4 ms 2412 KB Output is correct
19 Correct 11 ms 2412 KB Output is correct
20 Correct 15 ms 2412 KB Output is correct
21 Correct 10 ms 2412 KB Output is correct
22 Correct 22 ms 2412 KB Output is correct
23 Correct 2 ms 1516 KB Output is correct
24 Correct 7 ms 2540 KB Output is correct
25 Correct 2 ms 1388 KB Output is correct
26 Correct 10 ms 2412 KB Output is correct
27 Correct 8 ms 2412 KB Output is correct
28 Correct 17 ms 2412 KB Output is correct
29 Correct 18 ms 2412 KB Output is correct
30 Correct 2 ms 1516 KB Output is correct
31 Correct 80 ms 7788 KB Output is correct
32 Correct 179 ms 8172 KB Output is correct
33 Correct 88 ms 3180 KB Output is correct
34 Correct 88 ms 2412 KB Output is correct
35 Correct 91 ms 2412 KB Output is correct
36 Correct 112 ms 2412 KB Output is correct
37 Correct 82 ms 2560 KB Output is correct
38 Correct 73 ms 1644 KB Output is correct
39 Correct 104 ms 7360 KB Output is correct
40 Correct 76 ms 4204 KB Output is correct
41 Correct 73 ms 2924 KB Output is correct
42 Correct 89 ms 7916 KB Output is correct
43 Correct 86 ms 4332 KB Output is correct
44 Correct 67 ms 1388 KB Output is correct
45 Correct 85 ms 8684 KB Output is correct
46 Correct 86 ms 5612 KB Output is correct
47 Correct 99 ms 2412 KB Output is correct
48 Correct 76 ms 8044 KB Output is correct
49 Correct 78 ms 7148 KB Output is correct
50 Correct 207 ms 7220 KB Output is correct
51 Correct 98 ms 8300 KB Output is correct
52 Correct 101 ms 7232 KB Output is correct
53 Correct 539 ms 7312 KB Output is correct
54 Correct 234 ms 7248 KB Output is correct
55 Correct 206 ms 7220 KB Output is correct
56 Correct 214 ms 7488 KB Output is correct
57 Correct 236 ms 7616 KB Output is correct
58 Correct 208 ms 7528 KB Output is correct