제출 #900166

#제출 시각아이디문제언어결과실행 시간메모리
900166mariaclara은행 (IZhO14_bank)C++17
100 / 100
80 ms8656 KiB
#include<bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int,int> pii; const int MAXN = (1<<20)+5; #define all(x) x.begin(), x.end() #define mk make_pair #define pb push_back #define fr first #define sc second int n, m, a[25], b[25], prefix[25], dp[MAXN], sum[MAXN]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cin >> n >> m; for(int i = 1; i <= n; i++) cin >> a[i], prefix[i] = prefix[i-1] + a[i]; for(int i = 1; i <= m; i++) cin >> b[i]; for(int mask = 1; mask < (1<<m); mask++) { for(int j = 0; j < m; j++) { if(((1<<j) & mask) == 0) continue; sum[mask] = sum[mask - (1<<j)] + b[j+1]; dp[mask] = max(dp[mask], dp[mask - (1<<j)]); } if(sum[mask] == prefix[dp[mask]+1]) dp[mask]++; } if(dp[(1<<m) - 1] == 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...