# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
699803 |
2023-02-18T03:50:27 Z |
hazzle |
Bank (IZhO14_bank) |
C++17 |
|
106 ms |
8652 KB |
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define fi first
#define se second
#define all(m) (m).begin(), (m).end()
#define rall(m) (m).rbegin(), (m).rend()
#define vec vector
#define sz(a) (int) (a).size()
#define mpp make_pair
#define mtt make_tuple
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair <int, int> pii;
typedef tuple <int, int, int> tui;
template <typename T> bool umin(T &a, T b) { return a > b ? a = b, 1 : 0; }
template <typename T> bool umax(T &a, T b) { return a < b ? a = b, 1 : 0; }
int solve(){
int n, m;
cin >> n >> m;
vec <int> a(n), b(m);
for (auto &i: a) cin >> i;
for (auto &i: b) cin >> i;
vec <int> dp(1 << m, -1), le(1 << m, -1);
dp[0] = le[0] = 0;
for (int msk = 1; msk < (1 << m); ++msk){
for (int i = 0; i < m; ++i){
if (~msk >> i & 1) continue;
int prv = msk ^ (1 << i);
if (dp[prv] == -1) continue;
int cur = le[prv] + b[i];
if (cur == a[dp[prv]]){
if (umax(dp[msk], dp[prv] + 1)) le[msk] = 0;
}
if (cur < a[dp[prv]]){
if (umax(dp[msk], dp[prv])) le[msk] = cur;
}
}
}
for (int msk = 0; msk < (1 << m); ++msk){
if (dp[msk] == n){
cout << "YES\n";
return 0;
}
}
cout << "NO\n";
return 0;
}
signed main(){
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int tst = 1; //cin >> tst;
while(tst--) solve();
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
2 ms |
468 KB |
Output is correct |
5 |
Correct |
49 ms |
8536 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
74 ms |
8532 KB |
Output is correct |
9 |
Correct |
68 ms |
8532 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 |
1 ms |
324 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
324 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
320 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
444 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 |
432 KB |
Output is correct |
11 |
Correct |
2 ms |
360 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
2 ms |
468 KB |
Output is correct |
5 |
Correct |
49 ms |
8536 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
74 ms |
8532 KB |
Output is correct |
9 |
Correct |
68 ms |
8532 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
0 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
324 KB |
Output is correct |
13 |
Correct |
0 ms |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Correct |
1 ms |
212 KB |
Output is correct |
16 |
Correct |
1 ms |
324 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Correct |
1 ms |
212 KB |
Output is correct |
19 |
Correct |
1 ms |
320 KB |
Output is correct |
20 |
Correct |
1 ms |
340 KB |
Output is correct |
21 |
Correct |
1 ms |
340 KB |
Output is correct |
22 |
Correct |
1 ms |
340 KB |
Output is correct |
23 |
Correct |
1 ms |
340 KB |
Output is correct |
24 |
Correct |
1 ms |
340 KB |
Output is correct |
25 |
Correct |
1 ms |
340 KB |
Output is correct |
26 |
Correct |
1 ms |
444 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 |
432 KB |
Output is correct |
30 |
Correct |
2 ms |
360 KB |
Output is correct |
31 |
Correct |
87 ms |
8532 KB |
Output is correct |
32 |
Correct |
89 ms |
8532 KB |
Output is correct |
33 |
Correct |
66 ms |
8532 KB |
Output is correct |
34 |
Correct |
49 ms |
8532 KB |
Output is correct |
35 |
Correct |
47 ms |
8532 KB |
Output is correct |
36 |
Correct |
47 ms |
8508 KB |
Output is correct |
37 |
Correct |
48 ms |
8532 KB |
Output is correct |
38 |
Correct |
48 ms |
8532 KB |
Output is correct |
39 |
Correct |
60 ms |
8524 KB |
Output is correct |
40 |
Correct |
48 ms |
8544 KB |
Output is correct |
41 |
Correct |
48 ms |
8532 KB |
Output is correct |
42 |
Correct |
106 ms |
8528 KB |
Output is correct |
43 |
Correct |
52 ms |
8532 KB |
Output is correct |
44 |
Correct |
48 ms |
8652 KB |
Output is correct |
45 |
Correct |
106 ms |
8532 KB |
Output is correct |
46 |
Correct |
80 ms |
8532 KB |
Output is correct |
47 |
Correct |
47 ms |
8532 KB |
Output is correct |
48 |
Correct |
65 ms |
8532 KB |
Output is correct |
49 |
Correct |
47 ms |
8532 KB |
Output is correct |
50 |
Correct |
68 ms |
8528 KB |
Output is correct |
51 |
Correct |
48 ms |
8532 KB |
Output is correct |
52 |
Correct |
54 ms |
8532 KB |
Output is correct |
53 |
Correct |
95 ms |
8532 KB |
Output is correct |
54 |
Correct |
90 ms |
8532 KB |
Output is correct |
55 |
Correct |
68 ms |
8532 KB |
Output is correct |
56 |
Correct |
69 ms |
8532 KB |
Output is correct |
57 |
Correct |
71 ms |
8528 KB |
Output is correct |
58 |
Correct |
70 ms |
8504 KB |
Output is correct |