Submission #68556

#TimeUsernameProblemLanguageResultExecution timeMemory
68556hamzqq9Bank (IZhO14_bank)C++14
100 / 100
194 ms18940 KiB
#include<bits/stdc++.h> #define st first #define nd second #define pb push_back #define ppb pop_back #define umax(x,y) x=max(x,y) #define umin(x,y) x=min(x,y) #define ll long long #define ii pair<int,int> #define iii pair<int,ii> #define sz(x) ((int) x.size()) #define orta ((bas+son)>>1) #define all(x) x.begin(),x.end() #define dbgs(x) cerr<<(#x)<<" --> "<<(x)<<" " #define dbg(x) cerr<<(#x)<<" --> "<<(x)<<endl;getchar() #define pw(x) (1<<(x)) #define inf 100000000 #define MOD 1000000007 #define N 400005 #define MAX 10000006 #define LOG 30 #define KOK 200 using namespace std; int n,m; int a[21],b[21],sum[pw(21)]; bool vis[21][pw(20)]; vector<int> okey[21]; void dfs(int now,int mask) { if(now==n) { printf("YES"); exit(0); } if(vis[now][mask]) return ; vis[now][mask]=1; for(int i:okey[now]) { if(mask&i) continue ; dfs(now+1,mask|i); } } int main() { // freopen("input.txt","r",stdin); 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<pw(m);i++) { for(int j=0;j<m;j++) { if(i&pw(j)) { sum[i]=sum[i-pw(j)]+b[j]; break ; } } } for(int i=0;i<n;i++) { for(int j=0;j<pw(m);j++) { if(sum[j]==a[i]) { okey[i].pb(j); } } } dfs(0,0); printf("NO"); }

Compilation message (stderr)

bank.cpp: In function 'int main()':
bank.cpp:58:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d",&n,&m);
  ~~~~~^~~~~~~~~~~~~~~
bank.cpp:62:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d",&a[i]);
   ~~~~~^~~~~~~~~~~~
bank.cpp:68:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d",&b[i]);
   ~~~~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...