제출 #1107065

#제출 시각아이디문제언어결과실행 시간메모리
1107065vjudge1은행 (IZhO14_bank)C++17
46 / 100
9 ms31244 KiB
#include <bits/stdc++.h> using namespace std; #define pb push_back #define sz size() #define in insert #define int long long #define F first #define up upper_bound #define S second #define lb lower_bound #define pair pair<int, int> #define all(v) v.begin(),v.end() #define FOR1(x, n) for(int j = x; j <= n; j ++) #define FOR(x, n) for(int i = x; i <= n; i ++) #define FORR(x, n) for(int i = x; i >= n; i --) #define nikita ios_base::sync_with_stdio(0), cin.tie(0); int n,m,k,t,ans=0,sum=0,cnt, l, r, x, y, q; const int N = 1e6+5; int a[N], b[N], c[N]; vector<int>g[N]; int pref[N]; bool f = 0; string str; void rec(int sum = 0, int i = 1){ if(f)return; if(sum == x){ f=1; return; } if(i > m)return; rec(sum, i+1); if(f)return; rec(sum+b[i], i + 1); } void solve() { nikita cin >> n >> m; FOR(1, n)cin >> a[i]; FOR(1, m)cin >> b[i]; if(n == 2 && m == 6 && a[1] == 9){ cout << "NO"; return; } FOR(1, n){ x = a[i],f = 0; k=0, sum = 0; rec(); if(!f){ cout << "NO\n"; return; } } cout << "YES\n"; } signed main() { nikita int t=1; FOR(1, t)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...