# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
798581 |
2023-07-30T20:58:41 Z |
cryan |
Bank (IZhO14_bank) |
C++17 |
|
1000 ms |
112560 KB |
// oh, these hills, they burn so bright / oh, these hills, they bring me life
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define all(x) begin(x), end(x)
#define rall(x) x.rbegin(), x.rend()
#define sz(x) (int)(x.size())
#define inf 1000000010
#define linf 0x3f3f3f3f3f3f3f3f
#define mp make_pair
#define f first
#define s second
#define pi pair<int, int>
#ifdef __INTELLISENSE__
#include "/mnt/c/yukon/pp.hpp"
#endif
#ifndef LOCAL
#define endl "\n"
#else
#include "/mnt/c/yukon/pp.hpp"
#endif
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
int main() {
cin.tie(0)->sync_with_stdio(0);
int n, m;
cin >> n >> m;
vector<int> a(n + 1);
for (int i = 1; i <= n; i++) {
cin >> a[i];
}
vector<int> b(m);
for (int i = 0; i < m; i++) {
cin >> b[i];
}
vector<vector<vector<int>>> combos(n + 1);
for (int i = 1; i <= n; i++) {
vector<vector<vector<int>>> pp(a[i] + 1);
pp[0].push_back(vector<int>());
for (int bank = 0; bank < m; bank++) {
for (int val = 1; val <= a[i]; val++) {
if (val - b[bank] >= 0) {
int bruhmoment = sz(pp[val]);
for (auto kk : pp[val - b[bank]]) {
if (find(all(kk), bank) == kk.end()) {
pp[val].push_back(kk);
}
}
for (int l = bruhmoment; l < sz(pp[val]); l++) {
pp[val][l].push_back(bank);
}
}
}
}
combos[i] = pp[a[i]];
}
vector<vector<bool>> dp(n + 1, vector<bool>(1 << m, false));
dp[0][0] = 1;
for (int i = 1; i <= n; i++) {
for (auto &k : combos[i]) {
vector<int> pos;
int wahhhh = 0;
for (int gg = 0; gg < m; gg++) {
if (find(all(k), gg) == k.end()) {
pos.push_back(gg);
} else {
wahhhh += (1 << gg);
}
}
for (int mask = 0; mask < (1 << sz(pos)); mask++) {
int now = wahhhh;
for (int clown = 0; clown < sz(pos); clown++) {
if ((1 << clown) & mask) {
now += (1 << pos[clown]);
}
}
dp[i][now] = dp[i][now] || dp[i - 1][now - wahhhh];
//cout << i << ' ' << bitset<6>(mask) << ": " << dp[i][mask] << endl;
//cout << "REF: " << i - 1 << ' ' << bitset<6>(before) << endl;
if (i == n && dp[i][now]) {
cout << "YES" << endl;
return 0;
}
}
}
}
cout << "NO" << endl;
}
// don't get stuck on one approach
// question bounds
// flesh out your approach before implementing o.o
// math it out
// ok well X is always possible, how about X + 1 (etc.)
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
2 ms |
852 KB |
Output is correct |
5 |
Correct |
1 ms |
724 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
92 ms |
44748 KB |
Output is correct |
9 |
Correct |
220 ms |
112560 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
340 KB |
Output is correct |
8 |
Correct |
0 ms |
340 KB |
Output is correct |
9 |
Correct |
0 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
2 ms |
596 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
2 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
0 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
32 ms |
1740 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
2 ms |
852 KB |
Output is correct |
5 |
Correct |
1 ms |
724 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
92 ms |
44748 KB |
Output is correct |
9 |
Correct |
220 ms |
112560 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
0 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
0 ms |
212 KB |
Output is correct |
14 |
Correct |
0 ms |
212 KB |
Output is correct |
15 |
Correct |
0 ms |
212 KB |
Output is correct |
16 |
Correct |
0 ms |
340 KB |
Output is correct |
17 |
Correct |
0 ms |
340 KB |
Output is correct |
18 |
Correct |
0 ms |
340 KB |
Output is correct |
19 |
Correct |
1 ms |
340 KB |
Output is correct |
20 |
Correct |
1 ms |
340 KB |
Output is correct |
21 |
Correct |
2 ms |
596 KB |
Output is correct |
22 |
Correct |
1 ms |
340 KB |
Output is correct |
23 |
Correct |
2 ms |
340 KB |
Output is correct |
24 |
Correct |
1 ms |
340 KB |
Output is correct |
25 |
Correct |
0 ms |
340 KB |
Output is correct |
26 |
Correct |
1 ms |
340 KB |
Output is correct |
27 |
Correct |
1 ms |
340 KB |
Output is correct |
28 |
Correct |
1 ms |
340 KB |
Output is correct |
29 |
Correct |
1 ms |
340 KB |
Output is correct |
30 |
Correct |
32 ms |
1740 KB |
Output is correct |
31 |
Correct |
239 ms |
63332 KB |
Output is correct |
32 |
Correct |
581 ms |
40296 KB |
Output is correct |
33 |
Correct |
87 ms |
1876 KB |
Output is correct |
34 |
Correct |
44 ms |
1876 KB |
Output is correct |
35 |
Correct |
42 ms |
2004 KB |
Output is correct |
36 |
Correct |
106 ms |
3284 KB |
Output is correct |
37 |
Correct |
6 ms |
852 KB |
Output is correct |
38 |
Correct |
3 ms |
1108 KB |
Output is correct |
39 |
Correct |
659 ms |
1620 KB |
Output is correct |
40 |
Correct |
32 ms |
1876 KB |
Output is correct |
41 |
Correct |
49 ms |
3284 KB |
Output is correct |
42 |
Correct |
499 ms |
4180 KB |
Output is correct |
43 |
Correct |
118 ms |
1876 KB |
Output is correct |
44 |
Correct |
58 ms |
2624 KB |
Output is correct |
45 |
Correct |
166 ms |
1876 KB |
Output is correct |
46 |
Correct |
145 ms |
3284 KB |
Output is correct |
47 |
Correct |
67 ms |
2516 KB |
Output is correct |
48 |
Correct |
26 ms |
14268 KB |
Output is correct |
49 |
Correct |
1 ms |
724 KB |
Output is correct |
50 |
Execution timed out |
1086 ms |
3268 KB |
Time limit exceeded |
51 |
Halted |
0 ms |
0 KB |
- |