이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define debug if(0)
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int n; cin>>n;
vector<ll> a(n), pref(n);
vector<pair<ll, ll>> t;
for(int i=0; i<n; i++) {
cin>>a[i];
int cnt = 1, left = a[i];
while(left%2 == 0) {
cnt<<=1;
left>>=1;
}
t.push_back({left, cnt});
if(i == 0) pref[i] = cnt;
else pref[i] = pref[i-1]+cnt;
}
int q; cin>>q;
while(q--) {
ll x; cin>>x;
int lo = 0, hi = n-1;
while(lo < hi) {
int m = (lo+hi)/2;
if(pref[m] < x) lo = m+1;
else hi = m;
}
if(lo < 0) lo = 0;
cout<<t[lo].first<<"\n";
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |