Submission #580533

#TimeUsernameProblemLanguageResultExecution timeMemory
580533yutabiBank (IZhO14_bank)C++14
25 / 100
1094 ms4308 KiB
#include <bits/stdc++.h> using namespace std; #define pb push_back typedef long long ll; typedef pair <ll,ll> ii; int n; int m; vector <int> s; vector <int> x; int main() { scanf("%d %d",&n,&m); bool table[n+1][1<<m]; bool DP[n+1][1<<m]; for(int i=0;i<1<<m;i++) { DP[0][i]=1; table[0][i]=0; } for(int j=1;j<n+1;j++) { for(int i=0;i<1<<m;i++) { DP[j][i]=0; table[j][i]=0; } } for(int i=0;i<n;i++) { int a; scanf(" %d",&a); s.pb(a); } for(int i=0;i<m;i++) { int a; scanf(" %d",&a); x.pb(a); } for(int i=0;i<1<<m;i++) { int a=i; int sum=0; for(int j=0;j<m;j++,a/=2) { if(a%2) { sum+=x[j]; } } for(int j=0;j<n;j++) { if(s[j]==sum) { table[j][i]=1; } } } for(int i=0;i<n;i++) { for(int j=0;j<1<<m;j++) { for(int k=0;k<1<<m;k++) { if(((j&k)==0) && DP[i][j] && table[i][k]) { DP[i+1][j|k]=1; } } } } if(DP[n][(1<<m)-1]==1) { printf("YES"); } else { printf("NO"); } }

Compilation message (stderr)

bank.cpp: In function 'int main()':
bank.cpp:19:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   19 |     scanf("%d %d",&n,&m);
      |     ~~~~~^~~~~~~~~~~~~~~
bank.cpp:46:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   46 |         scanf(" %d",&a);
      |         ~~~~~^~~~~~~~~~
bank.cpp:55:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   55 |         scanf(" %d",&a);
      |         ~~~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...