이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
#define int long long
vector<int> a;
vector<int> f;
vector<int> s;
signed main(){
int n;
cin>>n;
a.resize(n);
s.resize(n);
f.resize(n);
for(int i = 0; i<n; i++){
cin>>a[i];
f[i] = a[i];
s[i] = 1LL;
while(f[i]%2 ==0){
f[i] = f[i]/2LL;
s[i] = s[i]*2LL;
}
if(i!=0){
s[i]+=s[i-1];
}
}
int q;
cin>>q;
for(int i = 0; i<q; i++){
int x;
cin>>x;
int id= 0;
if(s[0]>=x){
cout<<f[0]<<endl;
continue;
}
for(int step = (1LL<<20LL); step>=1; step/=2LL){
if(id+ step<n){
if(s[id+step]<x){
id+=step;
}
}
}
cout<<f[id+1]<<endl;
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |