제출 #592379

#제출 시각아이디문제언어결과실행 시간메모리
592379bLIC은행 (IZhO14_bank)C++17
19 / 100
103 ms8508 KiB
#include <bits/stdc++.h> using namespace std; #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(), x.rend() #define sz(x) (int)(x).size() #define ft first #define sd second #define pb push_back #define endl '\n' typedef long long ll; typedef pair<int, int> pii; typedef vector<int> vi; typedef vector<pii> vii; typedef vector<ll> vl; typedef vector<pair<ll, ll>> vll; #define dgb if(0) const ll MOD = 1e18; const int INF = 1e9; int n, m; void solve(){ cin>>n>>m; int a[n], b[m]; for (int i = 0;i<n;i++) cin>>a[i]; for (int i = 0;i<m;i++) cin>>b[i]; int covered[1<<m]{}, leftover[1<<m]{}; bool ans = false; for (int i = 1;i<(1<<m);i++){ for (int j = 0;j<m;j++){ if (i&(1<<j)){ int pre = i^(1<<j); if (leftover[pre]+b[j]==a[covered[pre]]) { covered[i] = covered[pre]+1; ans|=(covered[i]==n); leftover[i] = 0; } else if (leftover[pre]+b[j]<a[covered[pre]]) { covered[i] = covered[pre]; leftover[i] = leftover[pre]+b[j]; } } } } if (ans) cout<<"YES"; else cout<<"NO"; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); // freopen("movie.in", "r", stdin); // freopen("movie.out", "w", stdout); int t=1; // cin>>t; while(t--){ solve(); cout<<'\n'; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...