This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define mkp make_pair
#define PH push
#define PB push_back
#define REP(i,N) for( int i = 0; i < (N); ++i )
#define FOR(i,a,b) for( int i = (a); i <= (b); ++i )
#define ALL(x) begin(x), end(x)
#define MEM(x) memset(x, 0, sizeof(x))
typedef long long ll;
typedef pair<int,int> pii;
template<typename T>
using V=vector<T>;
void solve() {
int N; cin >> N;
V<pair<ll,ll>> vc(N);
for( auto &i : vc )
cin >> i.F, i.S = 1;
for( auto &i : vc ) {
while( i.F % 2 == 0 ) {
i.S <<=1;
i.F >>=1;
}
}
int Q; cin >> Q;
ll sum = 0;
int lpos = 0;
REP(i,Q) {
ll x; cin >> x;
while( sum+vc[lpos].S < x ) {
sum += vc[lpos].S;
lpos++;
}
cout << vc[lpos].F << '\n';
}
}
int main() {
int T = 1;
#ifdef LOCAL
freopen( "input.txt", "r", stdin);
freopen( "output.txt", "w", stdout );
cin >> T;
#else
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#endif
while(T--) solve();
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |