#include <bits/stdc++.h>
#define pb push_back
#define f first
#define s second
#define rep(X, a,b) for(int X=a;X<b;++X)
#define ALL(a) (a).begin(), (a).end()
#define SZ(a) (int)(a).size()
#define NL "\n"
using namespace std;
typedef pair<long long,long long> pll;
typedef pair<int,int> pii;
typedef long long ll;
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << "," << p.second << ')'; }
template<typename A> ostream& operator<<(ostream &os, const vector<A> &p){
for(const auto &a:p)
os << a << " ";
os << "\n";
return os;
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int n;
cin>>n;
vector<ll> ar(n), cnt(n), base(n);
rep(i,0,n) cin>>ar[i];
rep(i,0,n){
ll tmp=ar[i], num=0;
while(!(tmp&1)){
num++;
tmp/=2;
}
cnt[i]=(1ll<<num);
base[i]=tmp;
}
rep(i,1,n) cnt[i]+=cnt[i-1];
int q;
cin>>q;
while(q--){
ll x;
cin>>x;
int l=-1, r=n-1;
while(l<r-1){
int mid=(l+r)>>1;
if(cnt[mid]>=x) r=mid;
else l=mid;
}
cout<<base[r]<<NL;
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
21 ms |
5460 KB |
Output is correct |
4 |
Correct |
37 ms |
2748 KB |
Output is correct |
5 |
Correct |
54 ms |
7076 KB |
Output is correct |
6 |
Correct |
30 ms |
5388 KB |
Output is correct |
7 |
Correct |
51 ms |
7056 KB |
Output is correct |
8 |
Correct |
50 ms |
7188 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
316 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 |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
328 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
328 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
21 ms |
5460 KB |
Output is correct |
4 |
Correct |
37 ms |
2748 KB |
Output is correct |
5 |
Correct |
54 ms |
7076 KB |
Output is correct |
6 |
Correct |
30 ms |
5388 KB |
Output is correct |
7 |
Correct |
51 ms |
7056 KB |
Output is correct |
8 |
Correct |
50 ms |
7188 KB |
Output is correct |
9 |
Correct |
1 ms |
316 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 |
340 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Correct |
1 ms |
328 KB |
Output is correct |
19 |
Correct |
1 ms |
340 KB |
Output is correct |
20 |
Correct |
1 ms |
340 KB |
Output is correct |
21 |
Correct |
1 ms |
328 KB |
Output is correct |
22 |
Correct |
1 ms |
340 KB |
Output is correct |
23 |
Correct |
35 ms |
3276 KB |
Output is correct |
24 |
Correct |
50 ms |
6340 KB |
Output is correct |
25 |
Correct |
68 ms |
10376 KB |
Output is correct |
26 |
Correct |
47 ms |
6492 KB |
Output is correct |
27 |
Correct |
43 ms |
6616 KB |
Output is correct |
28 |
Correct |
96 ms |
10796 KB |
Output is correct |
29 |
Correct |
81 ms |
10176 KB |
Output is correct |
30 |
Correct |
43 ms |
3928 KB |
Output is correct |
31 |
Correct |
83 ms |
10640 KB |
Output is correct |