이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;
using pli = pair<ll,int>;
const char el = '\n';
int main() {
ios_base::sync_with_stdio(false), cin.tie(nullptr);
int n;
cin >> n;
vector<pli> PL; // position, length
ll cur_pos = 1LL;
for(int i=0, a, b, div; i<n; i++) {
cin >> a;
b = a;
div = 1;
while((b&1)==0) {
b >>= 1;
div <<= 1;
}
PL.push_back({cur_pos,a/div});
cur_pos += div;
}
int q;
cin >> q;
int pos;
ll x;
while(q--) {
cin >> x;
auto f = [&] (pli& pl) { return x>=pl.first; };
pos = distance(PL.begin(),
partition_point(PL.begin(),PL.end(),f));
pos--;
cout << PL[pos].second << el;
}
}
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |