Submission #1073085

#TimeUsernameProblemLanguageResultExecution timeMemory
1073085vjudge1Bank (IZhO14_bank)C++17
0 / 100
2 ms348 KiB
#include<bits/stdc++.h> using namespace std; #define ll long long #define mp make_pair #define ff first #define ss second #define pb push_back const ll MOD=1000000007; bool dp[20][(1<<20)]; void solve(){ int n,m; cin>>n>>m; int a[n],pr[n],b[m]; for(int i=0; i<n; i++){ cin>>a[i]; if(i==0) pr[i]=a[i]; else pr[i]=pr[i-1]+a[i]; } for(int i=0; i<m; i++) cin>>b[i]; sort(b,b+m); vector<int>ans; ans.pb(0); for(int i=0; i<n; i++){ vector<int>cur; for(int j=1; j<(1<<m); j++){ int sum=0; for(int k=0; k<m; k++) if((1<<k)&j) sum+=b[k]; if(sum>pr[i]) break; if(sum==pr[i]){ if(i==0) cur.pb(j); else for(int k=0; k<ans.size(); k++) if(ans[k]&j==ans[k]) cur.pb(j); } } ans=cur; } if(ans.size()>0) cout<<"YES"; else cout<<"NO"; } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); int t=1; // cin>>t; for(int _=0; _<t; _++){ // cout<<"Case "<<_+1<<":\n"; solve(); } return 0; } //080129552180

Compilation message (stderr)

bank.cpp: In function 'void solve()':
bank.cpp:33:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |     else for(int k=0; k<ans.size(); k++) if(ans[k]&j==ans[k]) cur.pb(j);
      |                       ~^~~~~~~~~~~
bank.cpp:33:53: warning: suggest parentheses around comparison in operand of '&' [-Wparentheses]
   33 |     else for(int k=0; k<ans.size(); k++) if(ans[k]&j==ans[k]) cur.pb(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...