제출 #344616

#제출 시각아이디문제언어결과실행 시간메모리
344616maskoff은행 (IZhO14_bank)C++14
0 / 100
3 ms2284 KiB
#include <bits/stdc++.h> #define file "" #define all(x) x.begin(), x.end() #define sc second #define fr first #define pb push_back #define mp make_pair using namespace std; typedef long long ll; typedef pair<int, int> pii; const ll inf = 1e18 + 5; const ll mod = 1e9 + 7; const int N = 5e5 + 5; int dx[] = {+1, 0, -1, 0}; int dy[] = {0, +1, 0, -1}; int n, m; int a[N], b[N]; void solve1() { vector<int> dp(N); dp[0] = true; for (int i = 1; i <= m; i++) { for (int w = 100; w >= 0; w--) { dp[w + b[i]] |= dp[w]; } } if (dp[a[1]]) cout << "YES", exit(0); else cout << "NO", exit(0); } int main() { ios_base :: sync_with_stdio(false); cin.tie(nullptr); srand(time(nullptr)); cin >> n >> m; for (int i = 1; i <= n; i++) cin >> a[i]; for (int i = 1; i <= m; i++) cin >> b[i]; if (n == 1) { solve1(); } 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...