제출 #1128369

#제출 시각아이디문제언어결과실행 시간메모리
1128369ImperialALEN은행 (IZhO14_bank)C++20
0 / 100
1 ms580 KiB
#include <bits/stdc++.h> // #pragma GCC optomize ("Ofast") // #pragma GCC optomize ("unroll-loops") // #pragma GCC target ("avx,avx2,fma") #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 good[N]; int have[N]; signed main(){ ios; int tt=1; // cin>>tt; while(tt--){ int n,m; cin>>n>>m; for(int i=1;i<=n;i++)cin>>a[i]; for(int i=1;i<=m;i++)cin>>b[i]; for(int mask=0;mask<(1<<m);mask++){ for(int i=0;i<m;i++){ if((mask & (1<<i))==0){ int pred=(mask & (1<<i)); int chel=a[good[pred]+1]; int use=have[pred]+b[i]; if(chel>use){ good[mask]=good[pred]; have[mask]=use; }else if(chel==use){ good[mask]=good[pred]+1; have[mask]=0; } } } 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...