제출 #534076

#제출 시각아이디문제언어결과실행 시간메모리
534076183234Intercastellar (JOI22_ho_t1)C++14
100 / 100
302 ms8436 KiB
#include <bits/stdc++.h> using namespace std; #define int long long int /* int log(int a, int n){ if(n < a) return 0; return log(n/a)+1; } int fac(int n){ if(n < 1) return 1; return n * fac(n-1); }*/ int a[200000]; int b[200000]; int pre[200010]; int q[200000]; int32_t main(){ int n; cin >> n; for(int i = 0; i < n; i++){ cin >> a[i]; } int Q; cin >> Q; for(int i = 0; i < Q; i++){ cin >> q[i]; } for(int i = 0; i < n; i++){ b[i] = 1; } for(int i = 0; i < n; i++){ while(a[i] % 2 == 0){ b[i] *= 2; a[i] /= 2; } //cout << "suichan " << i << ' ' << a[i] << ' ' << b[i] <<'\n'; } pre[0] = 0; for(int i = 0; i < n; i++){ pre[i+1] = pre[i]+b[i]; } for(int i = 0; i < Q; i++){ cout << a[(lower_bound(pre, pre+n+1, q[i])-pre)-1] << '\n'; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...