Submission #68489

#TimeUsernameProblemLanguageResultExecution timeMemory
68489tatatanBank (IZhO14_bank)C++11
100 / 100
645 ms18800 KiB
#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 (stderr)

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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...