제출 #970557

#제출 시각아이디문제언어결과실행 시간메모리
970557MercubytheFirst은행 (IZhO14_bank)C++14
19 / 100
1 ms512 KiB
#include "bits/stdc++.h" #define pb push_back #define endl '\n' #define fi first #define se second #define CDIV(a,b) (((a)+(b)-(1))/(b)) using ll = long long; using ld = long double; const ll inf = 1e15 + 37; const ll mod = 1e9 + 7; const ll N = 3e5 + 37; const ld eps = 1e-9; const ld PI = acos((ld)-1); template<typename T, size_t N> std::ostream& operator<<(std::ostream& os, const std::array<T, N>& a); template<typename T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& v); template<typename T1, typename T2> std::ostream& operator<<(std::ostream& os, const std::pair<T1, T2>& p); template<typename T> std::ostream& operator<<(std::ostream& os, const std::set<T>& s); template<typename T, typename cmp> std::ostream& operator<<(std::ostream& os, const std::set<T, cmp>& s); using namespace std; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); inline void solve(){ int n, m; cin >> n >> m; const int A = 1000; int dp[A + 37] = {}; vector<int> ppl(n), notes(m); for(int& i : ppl) cin >> i; for(int& i : notes) cin >> i; dp[0] = 1; for(int& note : notes) { for(int w = A; w >= note; --w) { dp[w] |= dp[w - note]; } } cout << (dp[ppl[0]] ? "YES" : "NO"); } signed main(){ std::ios_base::sync_with_stdio(0); std::cin.tie(NULL); // signed t; cin >> t; while(t--) solve(); } template<typename T, size_t N> std::ostream& operator<<(std::ostream& os, const std::array<T, N>& a) { os << "["; for(size_t i = 0; i + 1 < N; ++i) { os << a[i] << ", "; } if(N > 0) os << a[N - 1]; os << "]"; return os; } template<typename T1, typename T2> std::ostream& operator<<(std::ostream& os, const std::pair<T1, T2>& p) { os << "(" << p.first << ", " << p.second << ") "; return os; } template<typename T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& v) { os << '['; for(auto x : v) os << x << ", "; os << "] "; return os; } template<typename T> std::ostream& operator<<(std::ostream& os, const std::set<T>& s) { os << "{"; for(auto x : s) os << x << ", "; os << "} "; return os; } // template<typename T, typename cmp> std::ostream& operator<<(std::ostream& os, const std::set<T, cmp>& s) { os << "{"; for(auto x : s) os << x << ", "; os << "} "; return os; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...