이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int long long
#define endl "\n"
int mod=1e9+7;
const int N=2e5+5;
template<class x>
using ordered_multiset = tree<x, null_type,less_equal<x>, rb_tree_tag,tree_order_statistics_node_update>;
int n;
vector<pair<int,int> > v;
void cl(int x) {
int nm=x;
while (nm%2==0) {
nm/=2;
}
v.push_back({x/nm,nm});
}
signed main() {
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//freopen(".in", "r", stdin); freopen(".out", "w", stdout);
cin>>n;
for (int i=0;i<n;i++) {
int x; cin>>x;
cl(x);
}
pair<int,int> prfx[n+1];
for (int i=1;i<=n;i++) {
prfx[i].first=v[i-1].first+prfx[i-1].first;
prfx[i].second=v[i-1].second;
}
int q; cin>>q;
while (q--) {
int x; cin>>x;
pair<int,int> tmp={x,0};
int i=upper_bound(prfx+1,prfx+(n+1),tmp)-prfx+1;
i--;
cout<<prfx[i].second<<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... |