# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
815905 | vjudge1 | Intercastellar (JOI22_ho_t1) | C++17 | 283 ms | 10852 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 int long long
using namespace std;
void open(){
if(fopen("input.inp", "r")){
freopen("input.inp", "r", stdin);
//freopen("output.out", "w", stdout);
}
}
const int maxn = 2e5 + 5;
int n;
int A[maxn];
int q;
int lowest[maxn];
int depth[maxn];
signed main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
open();
cin >> n;
for(int i = 1; i <= n; i++){
cin >> A[i];
int temp = A[i];
int cnt = 0;
while(temp % 2 == 0){
temp /= 2;
cnt++;
}
lowest[i] = temp;
depth[i] = (1LL << cnt);
}
int cur_pos = 0;
int prefix = 0;
cin >> q;
while(q--){
int x;
cin >> x;
while(cur_pos < n && prefix < x){
prefix += depth[++cur_pos];
}
cout << lowest[cur_pos] << endl;
}
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... |