제출 #1007885

#제출 시각아이디문제언어결과실행 시간메모리
1007885arashmemar은행 (IZhO14_bank)C++17
0 / 100
0 ms348 KiB
#include <bits/stdc++.h> using namespace std; long long int a[30], b[30]; int dp[(1 << 20) + 20], ps[30]; int main() { ifstream cin("bank.in"); ofstream cout("bank.out"); int n, m; cin >> n >> m; for (int i = 0;i < n;i++) { cin >> a[i]; } ps[0] = a[0]; for (int i = 1;i < n;i++) { ps[i] = ps[i-1] + a[i]; } for (int i = 0;i < m;i++) { cin >> b[i]; } for (long long int mask = 1; mask < (1 << m);mask++) { int c = 1; int s = 0; for (int i = 0;i < m;i++) { if (mask & c) { s += b[i]; dp[mask] = max(dp[mask], dp[mask - c]); } c *= 2; } if (s == ps[dp[mask]]) { dp[mask]++; } } if (dp[(1 << m) - 1] == n) { 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...