Submission #868539

# Submission time Handle Problem Language Result Execution time Memory
868539 2023-10-31T17:38:22 Z truongdoan2012 Bank (IZhO14_bank) C++17
0 / 100
0 ms 600 KB
#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 time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 344 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 600 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 344 KB Output isn't correct
3 Halted 0 ms 0 KB -