제출 #960595

#제출 시각아이디문제언어결과실행 시간메모리
960595Kavelmydex은행 (IZhO14_bank)C++17
19 / 100
1 ms604 KiB
#include <bits/stdc++.h> using namespace std; // #define int long long #define pi pair<int,int> #define vi vector<int> #define rep(i,x,n) for(int i=x; i<n; ++i) #define For(i,n) rep(i,0,n) #define endl "\n" #define sp ' ' #define pb push_back #define f first #define s second #define sz size() #define all(x) (x).begin(),(x).end() const int N = 20, OO = 2e9, mod = 1e9+7, mx = 2e3+1; const int dx[]{0,1}, dy[]{1,0}; void tr(int a, int b){cout << a << sp << b << endl;} void cmx(int &a, int b){a = max(a,b);} void cmn(int &a, int b){a = min(a,b);} int dp[mx], a[N], b[N]; int32_t main() { ios::sync_with_stdio(0); cin.tie(0); // freopen("talent.in", "r", stdin); // freopen("talent.out", "w", stdout); int n,m; cin >> n >> m; For(i,n) cin >> a[i]; For(i,m) cin >> b[i]; dp[0] = 1; For(i,m){ for(int x=mx-1; x>=1; --x){ if(x-b[i] >= 0) { dp[x] |= dp[x-b[i]]; }else break; } } if(dp[a[0]]) cout << "YES"; else cout << "NO"; cout << endl; return 0; } /* Just some notices : I believe you can do it ! You've done things that were harder ... Stay calm and focused =) */
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...