제출 #893089

#제출 시각아이디문제언어결과실행 시간메모리
893089Andrey은행 (IZhO14_bank)C++14
100 / 100
138 ms11120 KiB
#include <bits/stdc++.h> using namespace std; int dp[2000000]; int sb[2000001]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n,m; cin >> n >> m; vector<int> haha(n); vector<int> bruh(m); for(int i = 0; i < n; i++) { cin >> haha[i]; if(i != 0) { haha[i]+=haha[i-1]; } } for(int i = 0; i < m; i++) { cin >> bruh[i]; } for(int i = 0; i < (1 << m); i++) { sb[i] = 0; for(int j = 0; j < m; j++) { if((1 << j)&i) { sb[i]+=bruh[j]; } } } dp[0] = 0; bool ans = false; for(int i = 1; i < (1 << m); i++) { dp[i] = 0; for(int j = 0; j < m; j++) { if((1 << j)&i) { dp[i] = max(dp[i],dp[i-(1 << j)]); } } if(haha[dp[i]] == sb[i]) { dp[i]++; } if(dp[i] == n) { ans = true; break; } } if(ans) { cout << "YES"; } else { cout << "NO"; } 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...