이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#define ll long long
#define vl vector<ll>
#define sl set<ll>
#define all(v) v.begin(), v.end()
#define pb push_back
#define s second
#define f first
#define pll pair<ll, ll>
#define pii pair<int, int>
using namespace std;
int main()
{
ll n, i, k, p, x, q;
cin >> n;
vl v(n);
for(ll&h : v) cin >> h;
vector<pair<ll, ll>>v1;
for(i = 0; i < n; i++)
{
p = v[i];
k = 1;
while(p % 2 == 0)
{
p /= 2;
k *= 2;
}
if(v1.empty()) v1.pb({k, p});
else v1.pb({k+v1.back().f, p});
}
cin >> q;
while(q--)
{
cin >> x;
cout << (*lower_bound(all(v1), pair<ll, ll>{x, 0})).s << "\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... |