Submission #868539

#TimeUsernameProblemLanguageResultExecution timeMemory
868539truongdoan2012Bank (IZhO14_bank)C++17
0 / 100
0 ms600 KiB
#include <bits/stdc++.h> using namespace std; #ifdef LOCAL #include "algo/debug.h" #else #define debug(...) 42 #endif using i64 = long long; const int N = 1022; int dp[N][N]; // can make sum j from i void solve() { int n, m; cin >> n >> m; vector<int> a(n), b(m); for (int &i : a) cin >> i; for (int &i : b) cin >> i; dp[0][0] = 1; for (int i = 1; i <= m; i++) { for (int j = 1000; j >= a[i - 1]; j--) { if (dp[i - 1][j - a[i - 1]]) { dp[i][j] = 1; } } } for (int j : a) { bool ok = 0; for (int i = 1; i <= m; i++) { if (dp[i][j]) ok = 1; } if (!ok) { cout << "NO\n"; return; } } cout << "YES\n"; } int main() { cin.tie(nullptr)->sync_with_stdio(false); int TC = 1; // cin >> TC; while (TC--) { solve(); } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...