#include <bits/stdc++.h>
using namespace std;
int main(){
//didn't a very similar problem come out for codeforces before? but actually this is easier :p
ios_base::sync_with_stdio(0); cin.tie(0);
int n; cin >> n;
long long cake[n];
for (int x = 0; x < n; x++) cin >> cake[x];
vector<pair<long long, long long>> decomp;
long long carry = 0;
for (int x = 0; x < n; x++){
long long woof = cake[x], meow = 1;
while (woof % 2 == 0){
woof /= 2; meow *= 2;
}
carry += meow;
decomp.push_back(make_pair(carry, woof));
}
int q; cin >> q; long long temp;
//lazy binsearch shld pass
for (int y = 0; y < q; y++){
cin >> temp;
cout << lower_bound(decomp.begin(), decomp.end(), make_pair(temp,0LL))->second << '\n';
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
22 ms |
6596 KB |
Output is correct |
4 |
Correct |
36 ms |
2832 KB |
Output is correct |
5 |
Correct |
57 ms |
7236 KB |
Output is correct |
6 |
Correct |
35 ms |
6348 KB |
Output is correct |
7 |
Correct |
53 ms |
7172 KB |
Output is correct |
8 |
Correct |
59 ms |
7264 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 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 |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
336 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
332 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
22 ms |
6596 KB |
Output is correct |
4 |
Correct |
36 ms |
2832 KB |
Output is correct |
5 |
Correct |
57 ms |
7236 KB |
Output is correct |
6 |
Correct |
35 ms |
6348 KB |
Output is correct |
7 |
Correct |
53 ms |
7172 KB |
Output is correct |
8 |
Correct |
59 ms |
7264 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
1 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 |
340 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
1 ms |
336 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 |
340 KB |
Output is correct |
20 |
Correct |
1 ms |
332 KB |
Output is correct |
21 |
Correct |
1 ms |
340 KB |
Output is correct |
22 |
Correct |
1 ms |
340 KB |
Output is correct |
23 |
Correct |
27 ms |
3344 KB |
Output is correct |
24 |
Correct |
40 ms |
7116 KB |
Output is correct |
25 |
Correct |
81 ms |
10416 KB |
Output is correct |
26 |
Correct |
60 ms |
6612 KB |
Output is correct |
27 |
Correct |
49 ms |
7236 KB |
Output is correct |
28 |
Correct |
79 ms |
10912 KB |
Output is correct |
29 |
Correct |
95 ms |
10400 KB |
Output is correct |
30 |
Correct |
44 ms |
3972 KB |
Output is correct |
31 |
Correct |
79 ms |
10764 KB |
Output is correct |