Submission #852639

#TimeUsernameProblemLanguageResultExecution timeMemory
852639batsukh2006Bank (IZhO14_bank)C++11
0 / 100
9 ms9916 KiB
#include<iostream> #include<stdio.h> #include<math.h> #include<map> #include<string> #include<algorithm> #include<vector> #include<string.h> #include<utility> #include<set> #include<cmath> #include<queue> #include<deque> #include<functional> #include<stack> #include<limits.h> #include<iomanip> #include<unordered_map> using namespace std; #define MOD 1000000007 #define int long long #define endl '\n' void solve(){ int n,m; cin>>n>>m; int a[n+1],b[m+1]; int sum=0; for(int i=1; i<=n; i++) cin>>a[i]; for(int i=1; i<=m; i++) cin>>b[i]; vector<vector<bool> > dp(n+1,vector<bool>(1<<m)); vector<int> v[200001]; for(int i=0; i<(1<<m); i++){ int sum=0; for(int j=0; j<m; j++){ if(i&(1<<j)) sum+=b[j]; } v[sum].push_back(i); } for(int i=1; i<=n; i++){ for(int j=0; j<(1<<m); j++){ if(dp[i-1][j]||i==0){ for(int l=0; l<v[i].size(); i++){ if(j&v[i][l]==0) dp[i][j|v[i][l]]=1; } } } } for(int i=0; i<(1<<m); i++){ if(dp[n][i]){ cout<<"YES"; return; } } cout<<"NO"; } signed main(){ // freopen("file.in", "r", stdin); // freopen("file.out", "w", stdout); ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int t=1; // cin>>t; while(t--){ solve(); cout<<endl; } return 0; }

Compilation message (stderr)

bank.cpp: In function 'void solve()':
bank.cpp:44:19: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   44 |     for(int l=0; l<v[i].size(); i++){
      |                  ~^~~~~~~~~~~~
bank.cpp:45:18: warning: suggest parentheses around comparison in operand of '&' [-Wparentheses]
   45 |      if(j&v[i][l]==0) dp[i][j|v[i][l]]=1;
bank.cpp:29:6: warning: unused variable 'sum' [-Wunused-variable]
   29 |  int sum=0;
      |      ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...