Submission #1017096

#TimeUsernameProblemLanguageResultExecution timeMemory
1017096davieduBank (IZhO14_bank)C++17
19 / 100
74 ms8540 KiB
#include <bits/stdc++.h> using namespace std; #define fastio ios_base::sync_with_stdio(0); cin.tie(0) #define all(a) a.begin(), a.end() #define rall(a) a.rbegin(), a.rend() #define ll long long struct P{ ll x, y; }; void dbg_out() { cerr << endl; } template <typename H, typename... T> void dbg_out(H h, T... t) { cerr << ' ' << h; dbg_out(t...); } #define dbg(...) { cerr << #__VA_ARGS__ << ':'; dbg_out(__VA_ARGS__); } signed main(){ fastio; int n, m; cin >> n >> m; vector<int> pay (n), notes (m); for (auto &a: pay) cin >> a; for (auto &a: notes) cin >> a; vector<pair<int, int>> dp ((1 << m), {-1, 0}); int a, b; bool ans=false; for (int i=0; i<n; i++){ for (int mask=1; mask<(1<<m); mask++){ if (dp[mask].first < i-1) continue; if (dp[mask].second == pay[i]) dp[mask].second = 0, dp[mask].first++; for (int j=0; j<m; j++){ if ((mask & (1 << j))) continue; dp[mask^(1<<j)] = {dp[mask].first, dp[mask].second+notes[j]}; } if (dp[mask].first == n-1) ans = true; } } cout << (ans? "YES" : "NO") << '\n'; }

Compilation message (stderr)

bank.cpp: In function 'int main()':
bank.cpp:26:9: warning: unused variable 'a' [-Wunused-variable]
   26 |     int a, b;
      |         ^
bank.cpp:26:12: warning: unused variable 'b' [-Wunused-variable]
   26 |     int a, b;
      |            ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...