# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
965497 | 2024-04-18T18:27:33 Z | 0x34c | Bank (IZhO14_bank) | C++17 | 53 ms | 16864 KB |
#include <bits/stdc++.h> #define ll long long #define pii pair<int, int> #define endl '\n' #define int ll using namespace std; signed main() { ios_base::sync_with_stdio(0); cin.tie(0); int N, M; cin >> N >> M; vector<int> ppl(N + 1), mny(M); for(int i = 0; i < N; i++) cin >> ppl[i]; ppl[N] = numeric_limits<int>::max(); for(int j = 0; j < M; j++) cin >> mny[j]; vector<int> pref_sol(1 << M, 0); vector<int> cur_sol(1 << M, 0); for(int mask = 1; mask < (1 << M); mask++) { for(int pick = 0; pick < M; pick++) { if(mask & (1 << pick) == 0) continue; int prev = mask & (~(1 << pick)); if(cur_sol[prev] + mny[pick] > ppl[pref_sol[prev]]) continue; else if(cur_sol[prev] + mny[pick] < ppl[pref_sol[prev]]) { cur_sol[mask] += mny[pick]; pref_sol[mask] = pref_sol[prev]; } else { cur_sol[prev] += mny[pick]; pref_sol[mask] = 1 + pref_sol[prev]; } } } if(pref_sol[(1 << M) - 1] == N) { cout << "YES" << endl; } else cout << "NO" << endl; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 3 ms | 860 KB | Output is correct |
5 | Correct | 53 ms | 16864 KB | Output is correct |
6 | Incorrect | 0 ms | 344 KB | Output isn't correct |
7 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 344 KB | Output is correct |
2 | Incorrect | 0 ms | 348 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 604 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 3 ms | 860 KB | Output is correct |
5 | Correct | 53 ms | 16864 KB | Output is correct |
6 | Incorrect | 0 ms | 344 KB | Output isn't correct |
7 | Halted | 0 ms | 0 KB | - |