#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define S second
#define F first
#define all(x) (x).begin(),(x).end()
#define sz size()
#define Yes cout << "YES" << endl
#define No cout << "NO" << endl
#define pb(x) push_back(x);
#define endl '\n'
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const int N=3e5+7;
ll INF=INT_MAX,mod=1e9+7;
int TT=1;
ll power(ll x, unsigned int y)
{
ll res = 1;
x = x; // % mod;
if (x == 0) return 0;
while (y > 0)
{
if (y & 1) res = (res*x) ; // % mod;
y = y>>1;
x = (x*x) ; // % mod;
}
return res;
}
ll n;
pair<ll,ll> a[N];
void solve()
{
cin >> n;
for(int i = 1; i <= n; i++) cin >> a[i].F;
for(int i = 1; i <= n; i++)
{
ll cnt = 1;
while(a[i].F%2==0) {cnt*=2; a[i].F/=2;}
a[i].S = cnt + a[i-1].S;
}
// for(int i = 1; i <= n ;i++) cout << a[i].S << " "; cout << endl;
ll q; cin >> q;
while(q--){
ll x; cin >> x;
ll l = 0, r = n;
while(l+1<r)
{
ll mid = (l+r)/2;
if(a[mid].S<x) l= mid; else r = mid;
}
cout << a[r].F << endl;
}
}
int main(){
//freopen("friday.in","r",stdin);
//freopen("friday.out","w" ,stdout);
fast;
while(TT--)
solve();
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
604 KB |
Output is correct |
3 |
Correct |
16 ms |
5432 KB |
Output is correct |
4 |
Correct |
23 ms |
3924 KB |
Output is correct |
5 |
Correct |
39 ms |
6616 KB |
Output is correct |
6 |
Correct |
22 ms |
5720 KB |
Output is correct |
7 |
Correct |
39 ms |
6748 KB |
Output is correct |
8 |
Correct |
39 ms |
6740 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
600 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
464 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
344 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
344 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
604 KB |
Output is correct |
3 |
Correct |
16 ms |
5432 KB |
Output is correct |
4 |
Correct |
23 ms |
3924 KB |
Output is correct |
5 |
Correct |
39 ms |
6616 KB |
Output is correct |
6 |
Correct |
22 ms |
5720 KB |
Output is correct |
7 |
Correct |
39 ms |
6748 KB |
Output is correct |
8 |
Correct |
39 ms |
6740 KB |
Output is correct |
9 |
Correct |
0 ms |
344 KB |
Output is correct |
10 |
Correct |
0 ms |
600 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
464 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
344 KB |
Output is correct |
16 |
Correct |
1 ms |
348 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
1 ms |
348 KB |
Output is correct |
20 |
Correct |
1 ms |
344 KB |
Output is correct |
21 |
Correct |
1 ms |
348 KB |
Output is correct |
22 |
Correct |
1 ms |
348 KB |
Output is correct |
23 |
Correct |
23 ms |
4700 KB |
Output is correct |
24 |
Correct |
26 ms |
5200 KB |
Output is correct |
25 |
Correct |
53 ms |
9852 KB |
Output is correct |
26 |
Correct |
35 ms |
5804 KB |
Output is correct |
27 |
Correct |
32 ms |
7508 KB |
Output is correct |
28 |
Correct |
60 ms |
10452 KB |
Output is correct |
29 |
Correct |
56 ms |
9808 KB |
Output is correct |
30 |
Correct |
30 ms |
5716 KB |
Output is correct |
31 |
Correct |
60 ms |
10392 KB |
Output is correct |