Submission #330699

# Submission time Handle Problem Language Result Execution time Memory
330699 2020-11-26T09:29:28 Z hakanai Bank (IZhO14_bank) C++17
27 / 100
2 ms 492 KB
// https://oj.uz/problem/view/IZhO14_bank

#include <bits/stdc++.h>

using namespace std;

const int N = 1010;
vector<int> mp[N];
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<N ) mp[res].push_back(s); 
    }
    set<int> avail;
    avail.insert((1<<m) - 1);
    for ( int i=0; i<n; i++ ) {
        set<int> navail;
        if ( avail.empty() ) {
            cout << "NO" << '\n';
            return 0;
        }
        for ( int t:mp[a[i]] ) {
            for ( int s:avail ) {
                if ( (t&s)==t&&(s^t)>0&&navail.count(s^t)==0 ) {
                    navail.insert(s^t);
                }
            }
        }
        avail = navail;
    }
    cout << "YES" << '\n';
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Incorrect 0 ms 364 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Incorrect 1 ms 364 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 364 KB Output is correct
2 Correct 2 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 2 ms 492 KB Output is correct
5 Correct 2 ms 492 KB Output is correct
6 Correct 2 ms 364 KB Output is correct
7 Correct 2 ms 364 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 2 ms 364 KB Output is correct
10 Correct 2 ms 364 KB Output is correct
11 Correct 2 ms 492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Incorrect 0 ms 364 KB Output isn't correct
3 Halted 0 ms 0 KB -