# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
768830 | NintsiChkhaidze | Intercastellar (JOI22_ho_t1) | C++17 | 298 ms | 12292 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define s second
#define f first
#define left (node<<1),l,((l+r)>>1)
#define right ((node<<1)|1),((l+r)>>1) + 1,r
#define pii pair <int,int>
#define int ll
using namespace std;
const int N = 2e5 + 5;
int a[N],pr[N];
pii v[N];
signed main() {
ios_base::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL);
int n;
cin>> n;
for (int i = 1; i <= n; i++)
cin>>a[i];
int id = 0;
for (int i= 1; i <= n; i++){
if (a[i] & 1) {
v[i] = {1,a[i]};
continue;
}
int x = 2;
for (int j = 1; j <= 50; j++){
if ((a[i] % (1LL<<j)) == 0){
x = (1LL<<j);
}else{
break;
}
}
v[i] = {x,a[i]/x};
}
for (int i = 1; i <= n; i++){
pr[i] = pr[i - 1] + v[i].f;
}
int Q;
cin>>Q;
while (Q--){
int x;
cin>>x;
int l = 1,r = n,res;
while (l <= r){
int mid = (l + r)/2;
if (pr[mid] >= x){
r = mid - 1;
res = mid;
}else{
l = mid + 1;
}
}
cout<<v[res].s<<endl;
}
}
컴파일 시 표준 에러 (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... |