Submission #885346

#TimeUsernameProblemLanguageResultExecution timeMemory
885346asli_bgBank (IZhO14_bank)C++11
100 / 100
93 ms8792 KiB
#include<bits/stdc++.h> using namespace std; #include <ext/pb_ds/assoc_container.hpp> #define FOR(i,a) for(int i=0;i<(a);i++) #define FORE(i,a,b) for(int i=(a);i<(b);i++) typedef long long ll; #define pb push_back #define se second #define fi first #define all(x) x.begin(),x.end() typedef pair<int,int> pii; typedef vector<int> vi; typedef vector<pii> vii; typedef vector<bool> vb; typedef vector<ll> vll; #define mid (l+r)/2 #define alt cout<<endl const int MAXN=25; const int INF=1e9; int32_t main(){ ios_base::sync_with_stdio(0); cin.tie(0); //ifstream cin ("movie.in"); //ofstream cout ("movie.out"); int n,m; cin>>n>>m; vii dp (1<<m); int people[n], money[m]; FOR(i,n){ cin>>people[i]; } FOR(i,m){ cin>>money[i]; } dp[0]={0,0}; bool flag=false; FORE(s,0,(1<<m)){ if(dp[s].fi==n){ flag=true; break; } FOR(j,m){ if(s & (1<<j)) continue; pii temp; if(people[dp[s].fi]==dp[s].se+money[j]){ temp={dp[s].fi+1,0}; } else{ temp={dp[s].fi,dp[s].se+money[j]}; } dp[s | (1<<j)]=max(dp[s| (1<<j)],temp); } } if(flag) cout<<"YES"; else cout<<"NO"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...