# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
945969 | 2024-03-14T09:13:29 Z | iaraha | Bank (IZhO14_bank) | C++14 | 383 ms | 92936 KB |
// Эксперт до 15.04.2024 Насиб #pragma GCC optimize ("Ofast") #include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; #define pf push_front #define pof pop_front #define pb push_back #define pob pop_back #define fi first #define se second #define Yes cout << "YES \n" #define No cout << "NO \n" #define Ferarri ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL); //////////////////// the code below //////////////////// bool dp[(1 << 21) + 5][25] = {}; signed main(){ Ferarri ll t = 1; //cin >> t; //cout << setprecision(8) << fixed; while (t --) { ll n, m; cin >> n >> m; ll a[n], b[m]; vector<ll>w[n + 5]; map<ll, ll>mp; for (ll i = 0; i < n; i++) { cin >> a[i]; } for (ll i = 0; i < m; i++) { cin >> b[i]; } for (ll i = 0; i < (1 << m); i++) { ll s = 0; for (ll j = 0; j < m; j++) { if (i & (1 << (m - j - 1))) { s += b[j]; } } mp[i] = s; } bool chk = 0; for (ll i = 0; i < n; i++) { for (ll j = 0; j < (1 << m); j++) { if (mp[j] == a[i]) { w[i].pb(j); if (i == 0) { dp[j][i] = 1; if (n == 1) chk = 1; } } } } for (ll i = 1; i < n; i++) { for (ll j = 0; j < w[i].size(); j++) { for (ll k = 0; k < w[i - 1].size(); k++) { if (!(w[i][j] & w[i - 1][k])) { dp[w[i][j] + w[i - 1][k]][i] = 1; if (i == n - 1) chk = 1; w[i][j] = w[i][j] + w[i - 1][k]; } } } } if (chk) Yes; else No; } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 348 KB | Output is correct |
2 | Correct | 1 ms | 348 KB | Output is correct |
3 | Correct | 1 ms | 536 KB | Output is correct |
4 | Correct | 10 ms | 4604 KB | Output is correct |
5 | Correct | 349 ms | 66020 KB | Output is correct |
6 | Correct | 1 ms | 344 KB | Output is correct |
7 | Correct | 1 ms | 604 KB | Output is correct |
8 | Correct | 383 ms | 92936 KB | Output is correct |
9 | Correct | 362 ms | 66104 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 348 KB | Output is correct |
2 | Correct | 1 ms | 344 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 1 ms | 348 KB | Output is correct |
5 | Incorrect | 1 ms | 344 KB | Output isn't correct |
6 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 11 ms | 3684 KB | Output is correct |
2 | Correct | 7 ms | 3420 KB | Output is correct |
3 | Correct | 14 ms | 3672 KB | Output is correct |
4 | Incorrect | 20 ms | 3420 KB | Output isn't correct |
5 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 348 KB | Output is correct |
2 | Correct | 1 ms | 348 KB | Output is correct |
3 | Correct | 1 ms | 536 KB | Output is correct |
4 | Correct | 10 ms | 4604 KB | Output is correct |
5 | Correct | 349 ms | 66020 KB | Output is correct |
6 | Correct | 1 ms | 344 KB | Output is correct |
7 | Correct | 1 ms | 604 KB | Output is correct |
8 | Correct | 383 ms | 92936 KB | Output is correct |
9 | Correct | 362 ms | 66104 KB | Output is correct |
10 | Correct | 1 ms | 348 KB | Output is correct |
11 | Correct | 1 ms | 344 KB | Output is correct |
12 | Correct | 0 ms | 348 KB | Output is correct |
13 | Correct | 1 ms | 348 KB | Output is correct |
14 | Incorrect | 1 ms | 344 KB | Output isn't correct |
15 | Halted | 0 ms | 0 KB | - |