Submission #68489

# Submission time Handle Problem Language Result Execution time Memory
68489 2018-08-17T08:14:00 Z tatatan Bank (IZhO14_bank) C++11
100 / 100
645 ms 18800 KB
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define LL long long
#define st first
#define nd second
#define endl '\n'
using namespace std;

int vis[1<<20],n,mo,a[21],m[20],val[1<<20],x;
vector<int> v[20005],ans[21];

int main() {

	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin>>n>>mo;
	for(int i=1;i<=n;++i) {
		cin>>a[i];
		a[i]+=a[i-1];
	}
	for(int i=0;i<mo;++i)
		cin>>m[i];
	for(int i=0;i<(1<<mo);++i) {
		vis[i]=1;
		for(int j=0;j<mo;++j)
			if((1<<j)&i)
				val[i]+=m[j];
		v[val[i]].pb(i);
	}
	for(int i=1;i<=n;++i) {
		for(int j=0;j<v[a[i]].size();++j) {
			if(vis[v[a[i]][j]])
				ans[i].pb(v[a[i]][j]);
		}
		memset(vis,0,sizeof vis);
		for(int j=0;j<ans[i].size();++j) {
			vis[ans[i][j]]=1;
		}
		for(int j=0;j<(1<<mo);++j) {
			if(!vis[j])
				continue;
			for(int k=0;k<mo;++k)
				if(!(j&(1<<k)))
					vis[j|(1<<k)]=1;
		}
		
	}
	if(ans[n].size()) cout<<"YES"<<endl;
	else cout<<"NO"<<endl;

}

Compilation message

bank.cpp: In function 'int main()':
bank.cpp:33:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int j=0;j<v[a[i]].size();++j) {
               ~^~~~~~~~~~~~~~~
bank.cpp:38:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int j=0;j<ans[i].size();++j) {
               ~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 5 ms 4984 KB Output is correct
2 Correct 5 ms 4988 KB Output is correct
3 Correct 5 ms 5048 KB Output is correct
4 Correct 9 ms 5352 KB Output is correct
5 Correct 89 ms 15472 KB Output is correct
6 Correct 5 ms 15472 KB Output is correct
7 Correct 6 ms 15472 KB Output is correct
8 Correct 112 ms 15472 KB Output is correct
9 Correct 86 ms 15472 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 15472 KB Output is correct
2 Correct 6 ms 15472 KB Output is correct
3 Correct 6 ms 15472 KB Output is correct
4 Correct 6 ms 15472 KB Output is correct
5 Correct 6 ms 15472 KB Output is correct
6 Correct 6 ms 15472 KB Output is correct
7 Correct 6 ms 15472 KB Output is correct
8 Correct 6 ms 15472 KB Output is correct
9 Correct 6 ms 15472 KB Output is correct
10 Correct 6 ms 15472 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 15472 KB Output is correct
2 Correct 7 ms 15472 KB Output is correct
3 Correct 10 ms 15472 KB Output is correct
4 Correct 9 ms 15472 KB Output is correct
5 Correct 9 ms 15472 KB Output is correct
6 Correct 8 ms 15472 KB Output is correct
7 Correct 7 ms 15472 KB Output is correct
8 Correct 7 ms 15472 KB Output is correct
9 Correct 8 ms 15472 KB Output is correct
10 Correct 9 ms 15472 KB Output is correct
11 Correct 9 ms 15472 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 4984 KB Output is correct
2 Correct 5 ms 4988 KB Output is correct
3 Correct 5 ms 5048 KB Output is correct
4 Correct 9 ms 5352 KB Output is correct
5 Correct 89 ms 15472 KB Output is correct
6 Correct 5 ms 15472 KB Output is correct
7 Correct 6 ms 15472 KB Output is correct
8 Correct 112 ms 15472 KB Output is correct
9 Correct 86 ms 15472 KB Output is correct
10 Correct 6 ms 15472 KB Output is correct
11 Correct 6 ms 15472 KB Output is correct
12 Correct 6 ms 15472 KB Output is correct
13 Correct 6 ms 15472 KB Output is correct
14 Correct 6 ms 15472 KB Output is correct
15 Correct 6 ms 15472 KB Output is correct
16 Correct 6 ms 15472 KB Output is correct
17 Correct 6 ms 15472 KB Output is correct
18 Correct 6 ms 15472 KB Output is correct
19 Correct 6 ms 15472 KB Output is correct
20 Correct 8 ms 15472 KB Output is correct
21 Correct 7 ms 15472 KB Output is correct
22 Correct 10 ms 15472 KB Output is correct
23 Correct 9 ms 15472 KB Output is correct
24 Correct 9 ms 15472 KB Output is correct
25 Correct 8 ms 15472 KB Output is correct
26 Correct 7 ms 15472 KB Output is correct
27 Correct 7 ms 15472 KB Output is correct
28 Correct 8 ms 15472 KB Output is correct
29 Correct 9 ms 15472 KB Output is correct
30 Correct 9 ms 15472 KB Output is correct
31 Correct 117 ms 15612 KB Output is correct
32 Correct 130 ms 15612 KB Output is correct
33 Correct 151 ms 15612 KB Output is correct
34 Correct 152 ms 15612 KB Output is correct
35 Correct 155 ms 16252 KB Output is correct
36 Correct 173 ms 16252 KB Output is correct
37 Correct 113 ms 16252 KB Output is correct
38 Correct 93 ms 16252 KB Output is correct
39 Correct 582 ms 16252 KB Output is correct
40 Correct 107 ms 16252 KB Output is correct
41 Correct 117 ms 16252 KB Output is correct
42 Correct 178 ms 16252 KB Output is correct
43 Correct 134 ms 16268 KB Output is correct
44 Correct 111 ms 16268 KB Output is correct
45 Correct 179 ms 16268 KB Output is correct
46 Correct 151 ms 16268 KB Output is correct
47 Correct 140 ms 16268 KB Output is correct
48 Correct 131 ms 16268 KB Output is correct
49 Correct 86 ms 16268 KB Output is correct
50 Correct 593 ms 17748 KB Output is correct
51 Correct 212 ms 17748 KB Output is correct
52 Correct 293 ms 17748 KB Output is correct
53 Correct 278 ms 17748 KB Output is correct
54 Correct 624 ms 17748 KB Output is correct
55 Correct 581 ms 17748 KB Output is correct
56 Correct 645 ms 18800 KB Output is correct
57 Correct 583 ms 18800 KB Output is correct
58 Correct 583 ms 18800 KB Output is correct