Submission #41236

# Submission time Handle Problem Language Result Execution time Memory
41236 2018-02-15T00:23:53 Z IvanC Bank (IZhO14_bank) C++14
100 / 100
298 ms 90096 KB
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 20;
const int MAXV = 1001;
const int MAXL = (1 << 20);
vector<int> possiveis[MAXN*MAXV];
int dp[MAXN][MAXL],n,m,vetor[MAXN],obj[MAXN];
int solve(int pos,int bitmask){
	if(pos == n) return 1;
	if(dp[pos][bitmask] != -1) return dp[pos][bitmask];
	for(int mascara : possiveis[vetor[pos]]){
		if(!(mascara & bitmask)){
			if(solve(pos+1,bitmask | mascara )) return dp[pos][bitmask] = 1;
		}
	}
	return dp[pos][bitmask] = 0;
}
void brute(int pos,int bitmask,int val){
	if(pos == m){
		possiveis[val].push_back(bitmask);
		return;
	}
	brute(pos+1,bitmask,val);
	brute(pos+1,bitmask | (1 << pos), val + obj[pos] );
}
int main(){
	cin >> n >> m;
	for(int i = 0;i<n;i++) cin >> vetor[i];
	for(int i = 0;i<m;i++) cin >> obj[i];
	brute(0,0,0);
	memset(dp,-1,sizeof(dp));
	if(solve(0,0)) printf("YES\n");
	else printf("NO\n");
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 57 ms 82908 KB Output is correct
2 Correct 57 ms 82976 KB Output is correct
3 Correct 60 ms 83024 KB Output is correct
4 Correct 58 ms 83208 KB Output is correct
5 Correct 79 ms 89160 KB Output is correct
6 Correct 57 ms 89160 KB Output is correct
7 Correct 69 ms 89160 KB Output is correct
8 Correct 79 ms 89160 KB Output is correct
9 Correct 81 ms 89160 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 66 ms 89160 KB Output is correct
2 Correct 65 ms 89160 KB Output is correct
3 Correct 65 ms 89160 KB Output is correct
4 Correct 64 ms 89160 KB Output is correct
5 Correct 56 ms 89160 KB Output is correct
6 Correct 58 ms 89160 KB Output is correct
7 Correct 57 ms 89160 KB Output is correct
8 Correct 112 ms 89160 KB Output is correct
9 Correct 66 ms 89160 KB Output is correct
10 Correct 57 ms 89160 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 66 ms 89160 KB Output is correct
2 Correct 57 ms 89160 KB Output is correct
3 Correct 58 ms 89160 KB Output is correct
4 Correct 56 ms 89160 KB Output is correct
5 Correct 56 ms 89160 KB Output is correct
6 Correct 62 ms 89160 KB Output is correct
7 Correct 57 ms 89160 KB Output is correct
8 Correct 57 ms 89160 KB Output is correct
9 Correct 57 ms 89160 KB Output is correct
10 Correct 57 ms 89160 KB Output is correct
11 Correct 67 ms 89160 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 57 ms 82908 KB Output is correct
2 Correct 57 ms 82976 KB Output is correct
3 Correct 60 ms 83024 KB Output is correct
4 Correct 58 ms 83208 KB Output is correct
5 Correct 79 ms 89160 KB Output is correct
6 Correct 57 ms 89160 KB Output is correct
7 Correct 69 ms 89160 KB Output is correct
8 Correct 79 ms 89160 KB Output is correct
9 Correct 81 ms 89160 KB Output is correct
10 Correct 66 ms 89160 KB Output is correct
11 Correct 65 ms 89160 KB Output is correct
12 Correct 65 ms 89160 KB Output is correct
13 Correct 64 ms 89160 KB Output is correct
14 Correct 56 ms 89160 KB Output is correct
15 Correct 58 ms 89160 KB Output is correct
16 Correct 57 ms 89160 KB Output is correct
17 Correct 112 ms 89160 KB Output is correct
18 Correct 66 ms 89160 KB Output is correct
19 Correct 57 ms 89160 KB Output is correct
20 Correct 66 ms 89160 KB Output is correct
21 Correct 57 ms 89160 KB Output is correct
22 Correct 58 ms 89160 KB Output is correct
23 Correct 56 ms 89160 KB Output is correct
24 Correct 56 ms 89160 KB Output is correct
25 Correct 62 ms 89160 KB Output is correct
26 Correct 57 ms 89160 KB Output is correct
27 Correct 57 ms 89160 KB Output is correct
28 Correct 57 ms 89160 KB Output is correct
29 Correct 57 ms 89160 KB Output is correct
30 Correct 67 ms 89160 KB Output is correct
31 Correct 86 ms 89952 KB Output is correct
32 Correct 80 ms 89952 KB Output is correct
33 Correct 88 ms 89952 KB Output is correct
34 Correct 90 ms 89952 KB Output is correct
35 Correct 99 ms 90080 KB Output is correct
36 Correct 97 ms 90080 KB Output is correct
37 Correct 91 ms 90080 KB Output is correct
38 Correct 93 ms 90080 KB Output is correct
39 Correct 79 ms 90080 KB Output is correct
40 Correct 91 ms 90080 KB Output is correct
41 Correct 89 ms 90080 KB Output is correct
42 Correct 84 ms 90080 KB Output is correct
43 Correct 87 ms 90096 KB Output is correct
44 Correct 102 ms 90096 KB Output is correct
45 Correct 82 ms 90096 KB Output is correct
46 Correct 82 ms 90096 KB Output is correct
47 Correct 97 ms 90096 KB Output is correct
48 Correct 83 ms 90096 KB Output is correct
49 Correct 81 ms 90096 KB Output is correct
50 Correct 178 ms 90096 KB Output is correct
51 Correct 81 ms 90096 KB Output is correct
52 Correct 81 ms 90096 KB Output is correct
53 Correct 298 ms 90096 KB Output is correct
54 Correct 206 ms 90096 KB Output is correct
55 Correct 165 ms 90096 KB Output is correct
56 Correct 174 ms 90096 KB Output is correct
57 Correct 196 ms 90096 KB Output is correct
58 Correct 99 ms 90096 KB Output is correct