제출 #1273434

#제출 시각아이디문제언어결과실행 시간메모리
1273434jakovg은행 (IZhO14_bank)C++20
0 / 100
1 ms572 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int maxn = 20; int n, m; int a[maxn], b[maxn]; int dp[1001][21]; int main() { ios::sync_with_stdio(false); cin >> n >> m; for (int i = 0; i < n; i++) cin >> a[i]; for (int i = 0; i < m; i++) cin >> b[i]; dp[0][0] = 1; for (int j = 0; j < m; j++) { for (int i = 1; i < 1001; i++) { if (i >= b[j]) dp[i][j] = max(dp[i][j - 1], dp[i - b[j]][j - 1]); if (j > 0) dp[i][j] = max(dp[i][j], dp[i][j - 1]); } } if (dp[a[0]][m - 1]) { cout << "YES\n"; } else { cout << "NO\n"; } 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...