Submission #676913

#TimeUsernameProblemLanguageResultExecution timeMemory
676913thegamercoder19Bank (IZhO14_bank)C++14
100 / 100
244 ms8532 KiB
/* Coded by thegamercoder19 GL */ #define _CRT_SECURE_NO_WARNINGS #include <bits/stdc++.h> #define M_PI 3.14159265358979323846 #define FILER 0 using ll = long long; using ull = unsigned long long; using ld = long double; const ll MOD = pow(10, 9) + 7; const ll INFL = 0x3f3f3f3f3f3f3f3f; const ull INFUL = 0x3f3f3f3f3f3f3f3f; const ll INFT = 0x3f3f3f3f; const ll MAX = 25; const ll S = 1e5; const ll MODD = 998244353; const double EPS = 1e-10; #define V vector #define pll pair<ll, ll> #define pull2 pair<ull,ull> #define MS multiset #define M map #define Q queue #define PQ priority_queue #define IOF ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); #define FOR(typ,i,a,b,c) for(typ i = a; i < b; i += c) #define FORR(typ,i,a,b,c) for(typ i = a; i > b; i -= c) #define FORA(a,i) for(auto &i : a) #define all(v) v.begin(),v.end() #define sz(v) v.size() #define sorta(a) sort(all(a)) #define sortd(a) sort(all(a), greater<ll>()) #define setp(x) setprecision(x)<<fixed #define RET return #define log(a,b) log(b)/log(a) #define WH(s) while(s) #define WHI(t) WH(t--) #define YES cout<<"YES"<<endl; #define NO cout<<"NO"<<endl; #define Yes cout<<"Yes"<<endl; #define No cout<<"No"<<endl; #define YESNO(s) cout<<(s?"YES":"NO")<<endl; #define YesNo(s) cout<<(s?"Yes":"No")<<endl; #define TYP 0 using namespace std; ll n, m; V<ll> a, b; V<ll> dp; bool chk(ll msk, ll i, ll x) { if (i == -1)return 1; if (!x) return chk(msk, i - 1, a[i-1]); if (!msk || x<0)return 0; if (dp[msk] != -1) return dp[msk]; bool res = 0; FOR(ll, j, 0, m, 1) if (((1 << j) & msk) && x>=b[j]) res = res || chk(msk ^ (1 << j), i, x - b[j]); return dp[msk]=res; } void solve() { cin >> n >> m; a.resize(n); b.resize(m); dp.resize((1 << m), -1); FOR(ll, i, 0, n, 1)cin >> a[i]; FOR(ll, i, 0, m, 1)cin >> b[i]; YESNO(chk((1 << m) - 1, n - 1, a[n - 1])); } void init() { if (FILER) { freopen("movie.in", "r", stdin); freopen("movie.out", "w", stdout); } } void handle() { init(); ll t = 1; if (TYP)cin >> t; WHI(t)solve(); } int main() { IOF handle(); RET 0; }

Compilation message (stderr)

bank.cpp: In function 'bool chk(ll, ll, ll)':
bank.cpp:63:19: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
   63 |     return dp[msk]=res;
bank.cpp: In function 'void init()':
bank.cpp:78:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   78 |         freopen("movie.in", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
bank.cpp:79:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   79 |         freopen("movie.out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...