Submission #93827

# Submission time Handle Problem Language Result Execution time Memory
93827 2019-01-11T21:54:05 Z dalgerok Bank (IZhO14_bank) C++14
19 / 100
180 ms 8700 KB
#include<bits/stdc++.h>
using namespace std;


const int N = 30, M = 21;



int n, m, a[N], b[N], sum[(1 << M)], dp[(1 << M)];



int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin >> n >> m;
    for(int i = 1; i <= n; i++){
        cin >> a[i];
        a[i] += a[i - 1];
    }
    for(int i = 0; i < m; i++){
        cin >> b[i];
    }
    for(int mask = 0; mask < (1 << m); mask++){
        if(dp[mask] >= n){
            return cout << "YES", 0;
        }
        for(int i = 0; i < m; i++){
            if((i >> mask) & 1){
                continue;
            }
            sum[mask ^ (1 << i)] = sum[mask] + b[i];
            if(a[dp[mask] + 1] == sum[mask] + b[i]){
                dp[mask ^ (1 << i)] = max(dp[mask ^ (1 << i)], dp[mask] + 1);
            }
            else{
                dp[mask ^ (1 << i)] = max(dp[mask ^ (1 << i)], dp[mask]);
            }
        }
    }
    cout << "NO";
}
# 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 177 ms 8536 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 3 ms 760 KB Output is correct
9 Correct 180 ms 8700 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 504 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 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 177 ms 8536 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 3 ms 760 KB Output is correct
9 Correct 180 ms 8700 KB Output is correct
10 Incorrect 2 ms 376 KB Output isn't correct
11 Halted 0 ms 0 KB -