제출 #385196

#제출 시각아이디문제언어결과실행 시간메모리
385196Aryan_Raina은행 (IZhO14_bank)C++14
52 / 100
1093 ms19820 KiB
#include <bits/stdc++.h> //#include "cyklib.hpp" using namespace std; #define int long long #define ld long double #define ar array const int INF = 1e15; const int MOD = 1e9+7; const int LIMIT = 1e18; const int MXN = 21; int dp[MXN][1<<MXN], a[MXN], b[MXN]; vector<int> smh[1005*MXN]; int32_t main() { ios_base::sync_with_stdio(0); cin.tie(0); 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]; for (int i = 0; i < 1<<m; i++) { int sum = 0; for (int j = 0; j < m; j++) if ((i>>j) & 1) { sum += b[j]; } smh[sum].push_back(i); } int ans = 0; for (int i = 0; i < n; i++) { for (int j = 0; j < 1<<m; j++) { for (int x : smh[a[i]]) if ((j & x) == 0) { dp[i+1][j ^ x] = max(dp[i+1][j ^ x], dp[i][j] + 1); ans = max(ans, dp[i+1][j ^ x]); } } } if (ans == n) { cout<<"YES\n"; } else cout<<"NO\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...