답안 #982196

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
982196 2024-05-14T02:39:37 Z Aiperiii Intercastellar (JOI22_ho_t1) C++14
100 / 100
155 ms 15684 KB
#include <bits/stdc++.h>
#define int long long
#define ull unsigned long long
#define ff first
#define ss second
#define pb push_back
#define all(x) x.begin(),x.end()
using namespace std;
const int N=2e5+5;
int kol[N],a[N],t[N*4];
void build(int v,int tl,int tr){
    if(tl==tr)t[v]=kol[tl];
    else{
        int tm=(tl+tr)/2;
        build(v*2,tl,tm);
        build(v*2+1,tm+1,tr);
        t[v]=t[v*2]+t[v*2+1];
    }
}
int get(int v,int tl,int tr,int x){
    if(tl==tr)return a[tl];
    else{
        int tm=(tl+tr)/2;
        if(t[v*2]<x)return get(v*2+1,tm+1,tr,x-t[v*2]);
        else return get(v*2,tl,tm,x);
    }
}
signed main(){
    ios_base::sync_with_stdio();
    cin.tie(0);cout.tie(0);
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
        if(a[i]%2==1)kol[i]=1;
        else{
            int x=a[i];
            int cnt=1;
            while(x%2==0){
                x/=2;
                cnt*=2;
            }
            kol[i]=cnt;
            a[i]=x;
        }
    }
    build(1,0,n-1);
    int q;
    cin>>q;
    while(q--){
        int pos;
        cin>>pos;
        cout<<get(1,0,n-1,pos)<<"\n";
    }
}
/*

 
*/




# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 33 ms 9820 KB Output is correct
4 Correct 47 ms 7000 KB Output is correct
5 Correct 81 ms 10036 KB Output is correct
6 Correct 51 ms 9656 KB Output is correct
7 Correct 81 ms 10064 KB Output is correct
8 Correct 82 ms 10152 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4440 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 4544 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Correct 1 ms 4444 KB Output is correct
10 Correct 1 ms 4696 KB Output is correct
11 Correct 1 ms 4444 KB Output is correct
12 Correct 1 ms 4444 KB Output is correct
13 Correct 1 ms 4444 KB Output is correct
14 Correct 1 ms 4444 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 33 ms 9820 KB Output is correct
4 Correct 47 ms 7000 KB Output is correct
5 Correct 81 ms 10036 KB Output is correct
6 Correct 51 ms 9656 KB Output is correct
7 Correct 81 ms 10064 KB Output is correct
8 Correct 82 ms 10152 KB Output is correct
9 Correct 1 ms 4440 KB Output is correct
10 Correct 1 ms 4444 KB Output is correct
11 Correct 1 ms 4444 KB Output is correct
12 Correct 1 ms 4444 KB Output is correct
13 Correct 1 ms 4544 KB Output is correct
14 Correct 1 ms 4444 KB Output is correct
15 Correct 1 ms 4444 KB Output is correct
16 Correct 1 ms 4444 KB Output is correct
17 Correct 1 ms 4444 KB Output is correct
18 Correct 1 ms 4696 KB Output is correct
19 Correct 1 ms 4444 KB Output is correct
20 Correct 1 ms 4444 KB Output is correct
21 Correct 1 ms 4444 KB Output is correct
22 Correct 1 ms 4444 KB Output is correct
23 Correct 46 ms 8784 KB Output is correct
24 Correct 70 ms 11860 KB Output is correct
25 Correct 121 ms 15032 KB Output is correct
26 Correct 85 ms 10320 KB Output is correct
27 Correct 81 ms 12368 KB Output is correct
28 Correct 153 ms 15684 KB Output is correct
29 Correct 149 ms 14932 KB Output is correct
30 Correct 78 ms 9760 KB Output is correct
31 Correct 155 ms 15440 KB Output is correct