# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
693612 |
2023-02-03T05:53:21 Z |
saayan007 |
Bank (IZhO14_bank) |
C++17 |
|
117 ms |
16844 KB |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pi = pair<int, int>;
using pl = pair<long long, long long>;
using vi = vector<int>;
using vl = vector<long long>;
using vpi = vector<pair<int, int>>;
using vpl = vector<pair<long long, long long>>;
#define fur(i, a, b) for(ll i = a; i <= (ll)b; ++i)
#define ruf(i, a, b) for(ll i = a; i >= (ll)b; --i)
#define fr first
#define sc second
#define mp make_pair
#define pb emplace_back
#define nl "\n"
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
ll n, m;
cin >> n >> m;
ll a[n], b[m];
for(auto &u : a)
cin >> u;
for(auto &u : b)
cin >> u;
ll M = 1 << m;
ll left[M];
ll done[M];
fur(i, 0, M - 1) {
left[i] = done[i] = -1;
}
left[0] = done[0] = 0;
fur(s, 0, M - 1) {
fur(last, 0, m - 1) {
if(!(s & (1 << last)))
continue;
ll prev = s ^ (1 << last);
if(done[prev] == -1) {
continue;
}
ll tot = left[prev] + b[last];
ll tar = a[done[prev]];
if(tot < tar) {
done[s] = done[prev];
left[s] = tot;
} else if(tot == tar) {
done[s] = done[prev] + 1;
left[s] = 0;
}
}
if(done[s] == n) {
cout << "YES" << nl;
return 0;
}
}
cout << "NO" << nl;
return 0;
}
# |
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 |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
724 KB |
Output is correct |
5 |
Correct |
55 ms |
16724 KB |
Output is correct |
6 |
Correct |
1 ms |
320 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
9 ms |
16708 KB |
Output is correct |
9 |
Correct |
94 ms |
16724 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 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 |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
468 KB |
Output is correct |
2 |
Correct |
2 ms |
468 KB |
Output is correct |
3 |
Correct |
1 ms |
468 KB |
Output is correct |
4 |
Correct |
1 ms |
448 KB |
Output is correct |
5 |
Correct |
2 ms |
468 KB |
Output is correct |
6 |
Correct |
1 ms |
468 KB |
Output is correct |
7 |
Correct |
2 ms |
468 KB |
Output is correct |
8 |
Correct |
1 ms |
468 KB |
Output is correct |
9 |
Correct |
1 ms |
468 KB |
Output is correct |
10 |
Correct |
1 ms |
448 KB |
Output is correct |
11 |
Correct |
1 ms |
468 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 |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
724 KB |
Output is correct |
5 |
Correct |
55 ms |
16724 KB |
Output is correct |
6 |
Correct |
1 ms |
320 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
9 ms |
16708 KB |
Output is correct |
9 |
Correct |
94 ms |
16724 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
0 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
1 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 |
212 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Correct |
1 ms |
212 KB |
Output is correct |
19 |
Correct |
0 ms |
212 KB |
Output is correct |
20 |
Correct |
1 ms |
468 KB |
Output is correct |
21 |
Correct |
2 ms |
468 KB |
Output is correct |
22 |
Correct |
1 ms |
468 KB |
Output is correct |
23 |
Correct |
1 ms |
448 KB |
Output is correct |
24 |
Correct |
2 ms |
468 KB |
Output is correct |
25 |
Correct |
1 ms |
468 KB |
Output is correct |
26 |
Correct |
2 ms |
468 KB |
Output is correct |
27 |
Correct |
1 ms |
468 KB |
Output is correct |
28 |
Correct |
1 ms |
468 KB |
Output is correct |
29 |
Correct |
1 ms |
448 KB |
Output is correct |
30 |
Correct |
1 ms |
468 KB |
Output is correct |
31 |
Correct |
108 ms |
16724 KB |
Output is correct |
32 |
Correct |
110 ms |
16672 KB |
Output is correct |
33 |
Correct |
65 ms |
16724 KB |
Output is correct |
34 |
Correct |
53 ms |
16700 KB |
Output is correct |
35 |
Correct |
58 ms |
16844 KB |
Output is correct |
36 |
Correct |
62 ms |
16724 KB |
Output is correct |
37 |
Correct |
52 ms |
16724 KB |
Output is correct |
38 |
Correct |
52 ms |
16704 KB |
Output is correct |
39 |
Correct |
9 ms |
16632 KB |
Output is correct |
40 |
Correct |
52 ms |
16692 KB |
Output is correct |
41 |
Correct |
53 ms |
16724 KB |
Output is correct |
42 |
Correct |
113 ms |
16724 KB |
Output is correct |
43 |
Correct |
62 ms |
16724 KB |
Output is correct |
44 |
Correct |
53 ms |
16708 KB |
Output is correct |
45 |
Correct |
10 ms |
16676 KB |
Output is correct |
46 |
Correct |
86 ms |
16724 KB |
Output is correct |
47 |
Correct |
54 ms |
16724 KB |
Output is correct |
48 |
Correct |
9 ms |
16664 KB |
Output is correct |
49 |
Correct |
54 ms |
16724 KB |
Output is correct |
50 |
Correct |
93 ms |
16724 KB |
Output is correct |
51 |
Correct |
59 ms |
16724 KB |
Output is correct |
52 |
Correct |
56 ms |
16724 KB |
Output is correct |
53 |
Correct |
117 ms |
16724 KB |
Output is correct |
54 |
Correct |
106 ms |
16696 KB |
Output is correct |
55 |
Correct |
106 ms |
16720 KB |
Output is correct |
56 |
Correct |
92 ms |
16712 KB |
Output is correct |
57 |
Correct |
106 ms |
16708 KB |
Output is correct |
58 |
Correct |
93 ms |
16724 KB |
Output is correct |