Submission #1038300

#TimeUsernameProblemLanguageResultExecution timeMemory
10383000pt1mus23Bank (IZhO14_bank)C++14
100 / 100
90 ms16876 KiB
#pragma GCC optimize("O3", "inline") #include <bits/stdc++.h> using namespace std; // #ifndef ONLINE_JUDGE // #include "0pt1z.hpp" // #else // #define dbg(...) // #endif mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); #define ins insert #define pb push_back #define int long long int #define pii pair<int, int> #define endl '\n' #define drop(x) cout<<(x)<<endl; return; #define all(x) x.begin(),x.end() #define hash z0hashp #define div z0dvp const int mod = 1e9 +7, sze = 1e5 +10, inf = LLONG_MAX, P = 1453; void opt1z(){ int n,m; cin>>n>>m; vector<int> people(n); for(int i=0;i<n;i++){ cin>>people[i]; } vector<int> notes(m); for(int j=0;j<m;j++){ cin>>notes[j]; } vector<int> left((1<<m),-1); vector<int> cover((1<<m),-1); left[0]=0; cover[0]=0; for(int i=0;i<(1<<m);i++){ for(int j=0;j<m;j++){ if(i & (1<<j)){ int prev = (i & ~(1<<j)); if(cover[prev]==-1){ continue; } int nw = left[prev] + notes[j]; int tar = people[cover[prev]]; if(nw<tar){ cover[i]=cover[prev]; left[i]=nw; } else if(nw==tar){ cover[i]=cover[prev]+1; left[i]=0; } } } if(cover[i]==n){ drop("YES"); } } drop("NO"); } signed main() { cin.tie(0)->sync_with_stdio(0); int tt = 1; // cin>>tt; while(tt--){ opt1z(); } return 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...