# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
527993 | amukkalir | Intercastellar (JOI22_ho_t1) | C++17 | 2083 ms | 9244 KiB |
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;
typedef long long ll;
#define prn printf
#define scn scanf
const int nax = 2e5;
ll p[nax+5]; //jumlahnya
ll v[nax+5]; // value nya
int n;
ll binser(ll x) {
ll lo = 1, hi = n;
ll ret = lo;
while(lo <= hi) {
int mid = (lo+hi)>>1;
if(x <= p[mid]) {
ret = mid;
hi = mid-1;
} else lo = mid+1;
}
return ret;
}
signed main () {
scn("%d", &n);
for(int i=1; i<=n; i++) {
ll a; scn("%lld", &a);
int cnt = 0;
while(a%2==0) {
cnt++;
a /= 2;
}
p[i] = 1ll<<cnt;
p[i] += p[i-1];
v[i] = a;
cerr << i << " " << p[i] << " " << v[i] << endl;
}
int q;
scn("%d", &q);
while(q--) {
ll x; scn("%lld", &x);
cerr << x << " " << binser(x) << endl;
prn("%lld\n", v[binser(x)]);
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |