# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
816517 | 2023-08-09T05:25:39 Z | vjudge1 | Intercastellar (JOI22_ho_t1) | C++17 | 1 ms | 332 KB |
#include <bits/stdc++.h> using namespace std; #ifdef LOCAL #include "/home/trucmai/.vim/tools.h" #define debug(x...) cerr << "\e[91m"<<__func__<<":"<<__LINE__<<" [" << #x << "] = ["; _print(x); cerr << "\e[39m" << endl; #else #define debug(x...) #endif void open(){ if(fopen("i.inp","r")){ freopen("i.inp","r",stdin); freopen("o.out","w",stdout); } } #define ll long long #define all(a) (a).begin(), (a).end() #define vi vector<ll> #define pi pair<ll,ll> #define pii pair<ll,pair<ll,ll>> #define fi first #define se second #define gcd __gcd #define mset(a,v) memset(a, v, sizeof(a)) #define endl '\n' #define spc " " const int MN = 1e6 + 5,LOG = 27; const ll MOD = 1e9 + 7,INF = 1e9; ll n,q,a[MN],len[MN]; void solve(){ cin>>n>>q; ll cnt = 1l; for(ll i = 1;i <= n;++i){ cin>>a[i]; if(!(a[i]&1)){ while(a[i] % 2 == 0) a[i] /=2; cnt >>= 1; } len[i] = len[i-1] + cnt; } while(q--){ ll x; cin>>x; ll l = 1,r = n,res = -1; while(l <= r){ ll m = (r+l) >> 1; if(len[m] >= x){ r = m - 1; res = a[m]; }else l = m + 1; } cout<<res<<endl; } } signed main(){ cin.tie(0) -> sync_with_stdio(0); open(); ll t = 1; //cin>>t; while(t--) solve(); #ifdef LOCAL cerr << endl << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n"; #endif }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Incorrect | 0 ms | 332 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Incorrect | 1 ms | 212 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Incorrect | 0 ms | 332 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |