Submission #523707

#TimeUsernameProblemLanguageResultExecution timeMemory
523707tmn2005Bank (IZhO14_bank)C++17
0 / 100
3 ms4996 KiB
#include<bits/stdc++.h> using namespace std; typedef long long ll; #define fr first #define sc second #define vec vector #define ret return #define ins insert #define mk make_pair #define pb push_back #define pii pair<int,int> #define all(s) s.begin(), s.end() #define allr(s) s.rbegin(), s.rend() const int N = 2e5+12, INF = 1e9, mod = 1e9+7; int a[N], b[N], dp[N]; vector<int>g[N]; main(){ ios::sync_with_stdio(0), cin.tie(0); int n, m; cin>>n>>m; for(int i=0; i<n; i++){ cin>>a[i]; } for(int j=0; j<m; j++){ cin>>b[j]; } for(int mask=0; mask<(1<<m); mask++){ int ans = 0; for(int i=0; i<m; i++){ if(mask & (i<<i)){ ans += b[i]; } } for(int i=0; i<n; i++){ if(ans == a[i]){ g[i].pb(mask); } } } dp[0] = 1; for(int i=0; i<n; i++){ for(int mask=(1<<m)-1; mask>=0; mask--){ if(dp[mask] > 0){ for(int ms : g[i]){ if(ms & mask)continue; int x = ms | mask; dp[x] = max(dp[x], dp[mask] + 1); if(dp[x] > n){ cout<<"YES"<<endl; return 0; } } } } } cout<<"NO"<<endl; return 0; }

Compilation message (stderr)

bank.cpp:23:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   23 | main(){
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...