# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
191345 | 2020-01-14T20:11:26 Z | rzbt | Bank (IZhO14_bank) | C++14 | 82 ms | 504 KB |
#include <bits/stdc++.h> #define mp make_pair #define pb push_back #define F first #define S second #define all(x) x.begin(),x.end() #define MAXN 21 typedef long long ll; using namespace std; int n,m; int a[MAXN],b[MAXN]; vector<int> moze[MAXN]; bool dp[MAXN][1<<MAXN]; void resi(int koji,int maska){ //printf(" %d %d\n",koji,maska); if(koji==n){ printf("YES"); exit(0); } if(dp[koji][maska])return; dp[koji][maska]=true; for(auto x:moze[koji]) if(!(x & maska) && !dp[koji+1][x|maska]) resi(koji+1,x|maska); } int main() { scanf("%d %d", &n, &m); for(int i=0;i<n;i++) scanf("%d",a+i); for(int i=0;i<m;i++) scanf("%d",b+i); for(int i=1;i<(1<<m);i++){ int zbir=0; for(int j=0;j<m;j++){ if(i&(1<<j)){ zbir+=b[j]; } } //printf(" %d %d\n",i,zbir); for(int j=0;j<n;j++) if(a[j]==zbir)moze[j].pb(zbir); } resi(0,0); printf("NO"); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 504 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 408 KB | Output is correct |
4 | Correct | 4 ms | 376 KB | Output is correct |
5 | Correct | 81 ms | 376 KB | Output is correct |
6 | Correct | 2 ms | 376 KB | Output is correct |
7 | Correct | 2 ms | 296 KB | Output is correct |
8 | Correct | 81 ms | 376 KB | Output is correct |
9 | Correct | 82 ms | 408 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 | 376 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 504 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 408 KB | Output is correct |
4 | Correct | 4 ms | 376 KB | Output is correct |
5 | Correct | 81 ms | 376 KB | Output is correct |
6 | Correct | 2 ms | 376 KB | Output is correct |
7 | Correct | 2 ms | 296 KB | Output is correct |
8 | Correct | 81 ms | 376 KB | Output is correct |
9 | Correct | 82 ms | 408 KB | Output is correct |
10 | Incorrect | 2 ms | 376 KB | Output isn't correct |
11 | Halted | 0 ms | 0 KB | - |