이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pi pair<int, int>
#define pii pair<int, pair<int, int> >
#define fi first
#define se second
int n,k;
int A[200005], B[200005], P[200005];
void solve(){
cin >> n;
for(int i=1;i<=n;i++)cin >> A[i];
for(int i=1;i<=n;i++){
B[i] = 1;
while(A[i]%2 == 0)A[i] /= 2, B[i]*=2;
P[i] = P[i-1] + B[i];
}
int q;cin >> q;
while(q--){
int x;cin >> x;
int s = 1, e = n, ans = 0;
while(s <= e){
int m = (s + e)/2;
if(P[m] < x)ans = m, s = m + 1;
else e = m - 1;
}
cout << A[ans+1] << '\n';
}
}
main(){
ios::sync_with_stdio(0);cin.tie(0);
int t = 1;
//cin >> t;
while(t--){
solve();
}
}
컴파일 시 표준 에러 (stderr) 메시지
Main.cpp:33:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
33 | main(){
| ^~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |