제출 #100487

#제출 시각아이디문제언어결과실행 시간메모리
100487AbduM은행 (IZhO14_bank)C++14
0 / 100
2 ms384 KiB
/// In the name of GOD /// I love my MOTHER /// Only GOLD #include <bits/stdc++.h> #define sz(s) (ll)(s.size()) #define all(x) (x.begin(), x.end()) #define pb push_back #define pf push_front #define F first #define S second #define mp make_pair #define ort1 exit(0); #define nl endl #define rep(i, l, r) for(int i = (l); i <= (r); ++i) #define per(i, l, r) for(int i = (l); i >= (r); --i) #define TL clock() / (double)CLOCKS_PER_SEC #define NFS ios_base :: sync_with_stdio(0), cin.tie(0), cout.tie(0); using namespace std; typedef long long ll; typedef unsigned long long ull; typedef double db; typedef long double ld; const double pi = acos(-1.0); const double eps = 1e-9; const long long inf = 1e12 + 1; const long long INF = 1e18 + 1; const int mod = 1e9 + 7; const int N = 5e5 + 7; int n, m; int a[N]; int b[N]; int cnt; bool bl[N]; inline void rec(int id, int sum, int i) { if(sum == a[i]){ cnt++; return; } if(id > m){ return; } if(sum > a[i]){ return; } if(!bl[id + 1] && sum + b[id + 1] <= a[i]) bl[id + 1] = 1, rec(id + 1, sum + b[id + 1], i); rec(id + 1, sum, i); } int main(){ NFS #ifdef ioi freopen("in.txt", "r", stdin); #else //freopen("bank.in", "r", stdin); //freopen("bank.out", "w", stdout); #endif cin >> n >> m; rep(i, 1, n){ cin >> a[i]; } rep(i, 1, m){ cin >> b[i]; } rep(i, 1, n){ rec(1, 0, i); } if(cnt == n) cout << "YES"; else cout << "NO"; ort1 }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...