Submission #283308

# Submission time Handle Problem Language Result Execution time Memory
283308 2020-08-25T14:14:40 Z keta_tsimakuridze Bank (IZhO14_bank) C++14
71 / 100
1000 ms 103032 KB
#include<bits/stdc++.h>
using namespace std;
int n,m,a[25],B[25],dp[2000006][25],i,j,k,s;
vector<int>V[25];
bool go(int b,int i){
	if(i==n) {
		return 1;
	}
	bool F=0;
	//cout<<i<<endl;
	if(dp[b][i]!=-1) return dp[b][i];
	for(int j=0;j<V[i].size();j++){
		if((b&V[i][j])==V[i][j]) {
			F=max(F,go(b^V[i][j],i+1));
		}
	}
	if (!F) {
		dp[b][i]=0; return 0;
	}
	return 1;
}
int main(){
	cin>>n>>m;
	for(k=0;k<n;k++){
		cin>>a[k];
	}
	for(k=0;k<m;k++)
	cin>>B[k];
	for(k=0;k<n;k++){
		s=0; 
		for(i=0;i< (1<<m); i++){
			s=0; dp[i][k]=-1;
			for(int j=0;j<=m;j++){
				int b=1<<j;
				if(b&i)s+=B[j];
			}
			if(s==a[k]) V[k].push_back(i);
		}
	}int b=1<<(m);
	if(go(b-1,0))cout<<"YES";
	else cout<<"NO";
}

Compilation message

bank.cpp: In function 'bool go(int, int)':
bank.cpp:12:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   12 |  for(int j=0;j<V[i].size();j++){
      |              ~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 4 ms 3584 KB Output is correct
5 Correct 120 ms 102904 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 512 KB Output is correct
8 Correct 120 ms 103032 KB Output is correct
9 Correct 122 ms 102984 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 1920 KB Output is correct
2 Correct 5 ms 1920 KB Output is correct
3 Correct 11 ms 1920 KB Output is correct
4 Correct 15 ms 1920 KB Output is correct
5 Correct 14 ms 1920 KB Output is correct
6 Correct 7 ms 1920 KB Output is correct
7 Correct 5 ms 1920 KB Output is correct
8 Correct 4 ms 1920 KB Output is correct
9 Correct 9 ms 1920 KB Output is correct
10 Correct 9 ms 1920 KB Output is correct
11 Correct 15 ms 1920 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 4 ms 3584 KB Output is correct
5 Correct 120 ms 102904 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 512 KB Output is correct
8 Correct 120 ms 103032 KB Output is correct
9 Correct 122 ms 102984 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 1 ms 384 KB Output is correct
16 Correct 1 ms 384 KB Output is correct
17 Correct 1 ms 384 KB Output is correct
18 Correct 1 ms 384 KB Output is correct
19 Correct 1 ms 384 KB Output is correct
20 Correct 8 ms 1920 KB Output is correct
21 Correct 5 ms 1920 KB Output is correct
22 Correct 11 ms 1920 KB Output is correct
23 Correct 15 ms 1920 KB Output is correct
24 Correct 14 ms 1920 KB Output is correct
25 Correct 7 ms 1920 KB Output is correct
26 Correct 5 ms 1920 KB Output is correct
27 Correct 4 ms 1920 KB Output is correct
28 Correct 9 ms 1920 KB Output is correct
29 Correct 9 ms 1920 KB Output is correct
30 Correct 15 ms 1920 KB Output is correct
31 Correct 195 ms 103032 KB Output is correct
32 Execution timed out 1062 ms 103032 KB Time limit exceeded
33 Halted 0 ms 0 KB -