# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
871125 | 2023-11-10T00:48:57 Z | Marco_Escandon | Intercastellar (JOI22_ho_t1) | C++11 | 445 ms | 10836 KB |
#include<bits/stdc++.h> using namespace std; typedef long long ll; struct st{ vector<ll> abi; void update(ll a,ll b) { for(a; a<abi.size(); a+=(a&-a)) { abi[a]+=b; } } ll query(ll a) { ll s=0; for(a; a>0; a-=(a&-a)) { s+=abi[a]; } return s; } st(ll n) { abi.resize(n*2); } }; int main() { ll n; cin>>n; ll cad[n+1]; st asd(n+1); for(int i=1; i<=n; i++) { cin>>cad[i]; ll temp=0; while(cad[i]%2==0) { cad[i]/=2; temp++; } asd.update(i,pow(2,temp)); } ll q; cin>>q; while(q--) { ll a=0, b=n+1; ll en; cin>>en; //cout<<asd.query(en)<<" "; while(abs(a-b)!=1) { ll m=(a+b)/2; if(asd.query(m)>=en) b=m; else a=m; } cout<<cad[b]<<"\n"; } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 89 ms | 5592 KB | Output is correct |
4 | Correct | 239 ms | 2644 KB | Output is correct |
5 | Correct | 365 ms | 6996 KB | Output is correct |
6 | Correct | 188 ms | 5380 KB | Output is correct |
7 | Correct | 368 ms | 7208 KB | Output is correct |
8 | Correct | 350 ms | 7352 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 344 KB | Output is correct |
3 | Correct | 1 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 1 ms | 348 KB | Output is correct |
7 | Correct | 1 ms | 348 KB | Output is correct |
8 | Correct | 2 ms | 348 KB | Output is correct |
9 | Correct | 1 ms | 348 KB | Output is correct |
10 | Correct | 1 ms | 348 KB | Output is correct |
11 | Correct | 2 ms | 348 KB | Output is correct |
12 | Correct | 3 ms | 348 KB | Output is correct |
13 | Correct | 2 ms | 348 KB | Output is correct |
14 | Correct | 2 ms | 344 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 89 ms | 5592 KB | Output is correct |
4 | Correct | 239 ms | 2644 KB | Output is correct |
5 | Correct | 365 ms | 6996 KB | Output is correct |
6 | Correct | 188 ms | 5380 KB | Output is correct |
7 | Correct | 368 ms | 7208 KB | Output is correct |
8 | Correct | 350 ms | 7352 KB | Output is correct |
9 | Correct | 0 ms | 348 KB | Output is correct |
10 | Correct | 0 ms | 344 KB | Output is correct |
11 | Correct | 1 ms | 348 KB | Output is correct |
12 | Correct | 0 ms | 348 KB | Output is correct |
13 | Correct | 0 ms | 348 KB | Output is correct |
14 | Correct | 1 ms | 348 KB | Output is correct |
15 | Correct | 1 ms | 348 KB | Output is correct |
16 | Correct | 2 ms | 348 KB | Output is correct |
17 | Correct | 1 ms | 348 KB | Output is correct |
18 | Correct | 1 ms | 348 KB | Output is correct |
19 | Correct | 2 ms | 348 KB | Output is correct |
20 | Correct | 3 ms | 348 KB | Output is correct |
21 | Correct | 2 ms | 348 KB | Output is correct |
22 | Correct | 2 ms | 344 KB | Output is correct |
23 | Correct | 199 ms | 3412 KB | Output is correct |
24 | Correct | 183 ms | 6224 KB | Output is correct |
25 | Correct | 401 ms | 10296 KB | Output is correct |
26 | Correct | 232 ms | 6736 KB | Output is correct |
27 | Correct | 201 ms | 6740 KB | Output is correct |
28 | Correct | 445 ms | 10836 KB | Output is correct |
29 | Correct | 424 ms | 10660 KB | Output is correct |
30 | Correct | 274 ms | 3848 KB | Output is correct |
31 | Correct | 427 ms | 10832 KB | Output is correct |