# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
801866 | vjudge1 | Intercastellar (JOI22_ho_t1) | C++14 | 82 ms | 9224 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>
#define fi first
#define se second
#define ll long long
using namespace std ;
const int N = 2e5 ;
ll n, q, pref[N + 10] ;
vector<pair<ll, ll>> v ;
main()
{
ios_base::sync_with_stdio( 0 ) ;
cin.tie( 0 ) ;
cout.tie( 0 ) ;
cin >> n ;
v.push_back({0, 0}) ;
for(ll i = 1 ; i <= n ; i++)
{
ll a, kol = 0 ;
cin >> a ;
while(!(a & 1))
{
kol++ ;
a >>= 1 ;
}
v.push_back({(1 << kol), a}) ;
}
cin >> q ;
for(int i = 1 ; i < v.size() ; i++)
pref[i] = pref[i - 1] + v[i].fi ;
while(q--)
{
ll x, l = 0, r = v.size() ;
cin >> x ;
while(l + 1 < r)
{
int mid = (l + r) >> 1 ;
if(pref[mid] < x)
l = mid ;
else
r = mid ;
}
cout << v[r].se << '\n' ;
}
return 0 ;
}
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... |