Submission #1128385

#TimeUsernameProblemLanguageResultExecution timeMemory
1128385ImperialALENBank (IZhO14_bank)C++20
52 / 100
2 ms584 KiB
#include <bits/stdc++.h> #define F first #define S second #define ll long long #define int long long #define pb push_back #define all(x) (x.begin(),x.end()) #define ios ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); using namespace std; const ll N = 2e4+7, INF = 1e18 , inf = 1e6, mod = 1e9+7; int a[22]; int b[22]; int have[N]; vector<int> good(N,-1); // #pragma GCC optomize ("Ofast") // #pragma GCC optomize ("unroll-loops") // #pragma GCC target ("avx,avx2,fma") signed main(){ ios; int tt=1; // cin>>tt; while(tt--){ int n,m; cin>>n>>m; for(int i=0;i<n;i++)cin>>a[i]; for(int i=0;i<m;i++)cin>>b[i]; good[0]=0; for(int mask=0;mask<(1<<m);mask++){ for(int i=0;i<m;i++){ if((mask & (1<<i))==0){ int nwmask=mask + (1<<i); if(a[good[mask]]==-1)continue; int use=have[mask]+b[i]; int chel=a[good[mask]]; if(use<chel){ good[nwmask]=good[mask]; have[nwmask]=use; }else if(use==chel){ good[nwmask]=good[mask]+1; have[nwmask]=0; } } } } for(int mask=0;mask<(1<<m);mask++){ if(good[mask]==n){ cout<<"YES"; return 0; } } 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...