#include <iostream>
#include <chrono>
#include <algorithm>
#define maxn 200005
#define maxlog 20
#define INF 1000000010
#define LINF 1000000000000000005
#define endl '\n'
#define pb(x) push_back(x)
#define X first
#define Y second
#define control cout<<"passed"<<endl;
#pragma GCC optimize("O3" , "Ofast" , "unroll-loops" , "fast-math")
#pragma GCC target("avx2")
using namespace std;
std::chrono::high_resolution_clock::time_point startT, currT;
constexpr double TIME_MULT = 1;
double timePassed()
{
using namespace std::chrono;
currT = high_resolution_clock::now();
double time = duration_cast<duration<double>>(currT - startT).count();
return time * TIME_MULT;
}
long long n , q;
long long a[maxn] , br[maxn];
void read()
{
cin >> n;
for(int i = 1; i <= n; i++)
cin >> a[i];
}
void solve()
{
for(int i = 1; i <= n; i++)
{
br[i] = 1;
while(a[i] % 2 == 0)
{
a[i] /= 2;
br[i] *= 2;
}
br[i] += br[i - 1];
}
}
void answer()
{
cin >> q;
long long pos;
while(q--)
{
cin >> pos;
cout << a[lower_bound(br + 1 , br + 1 + n , pos) - br] << endl;
}
}
int main()
{
/**#ifdef ONLINE_JUDGE
freopen("taxi.in", "r", stdin);
freopen("taxi.out", "w", stdout);
#endif*/
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
startT = std::chrono::high_resolution_clock::now();
read();
solve();
answer();
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2392 KB |
Output is correct |
2 |
Correct |
0 ms |
2396 KB |
Output is correct |
3 |
Correct |
21 ms |
3540 KB |
Output is correct |
4 |
Correct |
32 ms |
2908 KB |
Output is correct |
5 |
Correct |
39 ms |
3844 KB |
Output is correct |
6 |
Correct |
22 ms |
3420 KB |
Output is correct |
7 |
Correct |
39 ms |
3924 KB |
Output is correct |
8 |
Correct |
38 ms |
3924 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Correct |
0 ms |
2396 KB |
Output is correct |
3 |
Correct |
1 ms |
2396 KB |
Output is correct |
4 |
Correct |
1 ms |
2396 KB |
Output is correct |
5 |
Correct |
1 ms |
2396 KB |
Output is correct |
6 |
Correct |
1 ms |
2396 KB |
Output is correct |
7 |
Correct |
1 ms |
2392 KB |
Output is correct |
8 |
Correct |
1 ms |
2408 KB |
Output is correct |
9 |
Correct |
1 ms |
2396 KB |
Output is correct |
10 |
Correct |
1 ms |
2396 KB |
Output is correct |
11 |
Correct |
1 ms |
2396 KB |
Output is correct |
12 |
Correct |
1 ms |
2396 KB |
Output is correct |
13 |
Correct |
1 ms |
2396 KB |
Output is correct |
14 |
Correct |
1 ms |
2396 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2392 KB |
Output is correct |
2 |
Correct |
0 ms |
2396 KB |
Output is correct |
3 |
Correct |
21 ms |
3540 KB |
Output is correct |
4 |
Correct |
32 ms |
2908 KB |
Output is correct |
5 |
Correct |
39 ms |
3844 KB |
Output is correct |
6 |
Correct |
22 ms |
3420 KB |
Output is correct |
7 |
Correct |
39 ms |
3924 KB |
Output is correct |
8 |
Correct |
38 ms |
3924 KB |
Output is correct |
9 |
Correct |
1 ms |
2396 KB |
Output is correct |
10 |
Correct |
0 ms |
2396 KB |
Output is correct |
11 |
Correct |
1 ms |
2396 KB |
Output is correct |
12 |
Correct |
1 ms |
2396 KB |
Output is correct |
13 |
Correct |
1 ms |
2396 KB |
Output is correct |
14 |
Correct |
1 ms |
2396 KB |
Output is correct |
15 |
Correct |
1 ms |
2392 KB |
Output is correct |
16 |
Correct |
1 ms |
2408 KB |
Output is correct |
17 |
Correct |
1 ms |
2396 KB |
Output is correct |
18 |
Correct |
1 ms |
2396 KB |
Output is correct |
19 |
Correct |
1 ms |
2396 KB |
Output is correct |
20 |
Correct |
1 ms |
2396 KB |
Output is correct |
21 |
Correct |
1 ms |
2396 KB |
Output is correct |
22 |
Correct |
1 ms |
2396 KB |
Output is correct |
23 |
Correct |
23 ms |
4700 KB |
Output is correct |
24 |
Correct |
28 ms |
5716 KB |
Output is correct |
25 |
Correct |
53 ms |
8788 KB |
Output is correct |
26 |
Correct |
34 ms |
6224 KB |
Output is correct |
27 |
Correct |
32 ms |
5968 KB |
Output is correct |
28 |
Correct |
75 ms |
9316 KB |
Output is correct |
29 |
Correct |
64 ms |
8760 KB |
Output is correct |
30 |
Correct |
32 ms |
5688 KB |
Output is correct |
31 |
Correct |
59 ms |
9220 KB |
Output is correct |