#include <bits/stdc++.h>
using namespace std;
#define int long long
int32_t main(){
int n;
cin >> n;
int a[n];
int d[n];
int s[n];
for (int i = 0; i < n; i++){
cin >> a[i];
int count = 1;
while(a[i]%2==0){
a[i]/=2;
count*=2;
}
d[i] = count;
}
s[0]=d[0];
for (int i = 1; i < n; i++){
s[i]=s[i-1]+d[i];
//cout << "sum " << i << ": " << s[i] << "\n";
}
int q;
cin >> q;
int v;
for (int i = 0; i < q; i++){
cin >> v;
/*auto it = lower_bound(s,s+n,v);
if(*it==v){
cout << a[it-s];
continue;
}*/
int k = lower_bound(s,s+n,v)-s;
cout << a[k] << "\n";
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
92 ms |
4856 KB |
Output is correct |
4 |
Correct |
255 ms |
1708 KB |
Output is correct |
5 |
Correct |
356 ms |
5340 KB |
Output is correct |
6 |
Correct |
179 ms |
4340 KB |
Output is correct |
7 |
Correct |
364 ms |
5392 KB |
Output is correct |
8 |
Correct |
359 ms |
5364 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 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 |
2 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
3 ms |
212 KB |
Output is correct |
12 |
Correct |
2 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
2 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
92 ms |
4856 KB |
Output is correct |
4 |
Correct |
255 ms |
1708 KB |
Output is correct |
5 |
Correct |
356 ms |
5340 KB |
Output is correct |
6 |
Correct |
179 ms |
4340 KB |
Output is correct |
7 |
Correct |
364 ms |
5392 KB |
Output is correct |
8 |
Correct |
359 ms |
5364 KB |
Output is correct |
9 |
Correct |
0 ms |
212 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 |
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 |
2 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 |
3 ms |
212 KB |
Output is correct |
20 |
Correct |
2 ms |
212 KB |
Output is correct |
21 |
Correct |
1 ms |
212 KB |
Output is correct |
22 |
Correct |
2 ms |
212 KB |
Output is correct |
23 |
Correct |
218 ms |
2164 KB |
Output is correct |
24 |
Correct |
187 ms |
4300 KB |
Output is correct |
25 |
Correct |
405 ms |
6828 KB |
Output is correct |
26 |
Correct |
262 ms |
3848 KB |
Output is correct |
27 |
Correct |
211 ms |
4036 KB |
Output is correct |
28 |
Correct |
491 ms |
6064 KB |
Output is correct |
29 |
Correct |
462 ms |
5344 KB |
Output is correct |
30 |
Correct |
291 ms |
1552 KB |
Output is correct |
31 |
Correct |
491 ms |
5872 KB |
Output is correct |