제출 #843850

#제출 시각아이디문제언어결과실행 시간메모리
843850Elvin_Fritl은행 (IZhO14_bank)C++17
0 / 100
1 ms600 KiB
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops") #include <bits/stdc++.h> using namespace std; const int N = 25; vector<int>a(N),b(N); int n,m,ind[1<<20],dp[1<<20]; int32_t main() { cin>>n>>m; for(int i=0;i<n;i++){ cin>>a[i]; } for(int i=0;i<m;i++){ cin>>b[i]; } for(int mask = 0;mask < n;mask++){ for(int i=0;i<m;i++){ if(mask&(1<<i)){ if(dp[mask ^ (1 << i)] == -1){ continue; } int cur = a[dp[mask ^ (1<<i)]] , r = ind[mask ^ (1<<i)]; if(r + b[i] < cur) { dp[mask] = dp[mask ^ (1<<i)]; ind[mask] = r + b[i]; } else if(r + b[i] == cur) { dp[mask] = dp[mask ^ (1<<n)] + 1; ind[mask] = 0; } if(dp[mask] == N){ cout << "YES"; return 0; } } } } cout<<"NO\n"; return 0; } /* 1 1 2 2 3 3 4 4 1 */
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...