Submission #361579

#TimeUsernameProblemLanguageResultExecution timeMemory
361579shahriarkhanBank (IZhO14_bank)C++14
27 / 100
3 ms1408 KiB
#include<bits/stdc++.h> using namespace std ; int main() { int n , m ; scanf("%d%d",&n,&m) ; int a[n+1] , b[m+1] , sum[1<<m] , log[1<<m] , dp[n+1][1<<m] ; for(int i = 0 ; i < m ; ++i) log[1<<i] = i ; for(int i = 1 ; i <= n ; ++i) scanf("%d",&a[i]) ; for(int i = 1 ; i <= m ; ++i) scanf("%d",&b[i]) ; vector<int> pos[n+1] ; for(int i = 1 ; i < (1<<m) ; ++i) { sum[i] = sum[i - (i & -i)] + b[log[i & -i]+1] ; for(int j = 1 ; j <= n ; ++j) { if(a[j]==sum[i]) pos[j].push_back(i) ; } } for(int i = 0 ; i <= n ; ++i) { for(int j = 0 ; j < (1<<m) ; ++j) { dp[i][j] = 0 ; } } dp[0][0] = 1 ; for(int i = 1 ; i <= n ; ++i) { for(int j = 1 ; j < (1<<m) ; ++j) { for(int k : pos[i]) { if((j&k)!=k) continue ; dp[i][j] = dp[i-1][j^k] ; if(dp[i][j]) break ; } } } for(int i = 1 ; i < (1<<m) ; ++i) { if(dp[n][i]) { puts("YES") ; return 0 ; } } puts("NO") ; return 0 ; }

Compilation message (stderr)

bank.cpp: In function 'int main()':
bank.cpp:7:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    7 |     scanf("%d%d",&n,&m) ;
      |     ~~~~~^~~~~~~~~~~~~~
bank.cpp:10:40: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   10 |     for(int i = 1 ; i <= n ; ++i) scanf("%d",&a[i]) ;
      |                                   ~~~~~^~~~~~~~~~~~
bank.cpp:11:40: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   11 |     for(int i = 1 ; i <= m ; ++i) 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...