답안 #832964

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
832964 2023-08-21T17:15:24 Z LeVanThuc Intercastellar (JOI22_ho_t1) C++17
100 / 100
76 ms 9192 KB
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fi first
#define se second
#define p(x,y) pair<ll,ll>(x,y)
#define BIT(i,x) ((x>>i)&1)
#define MASK(x) (1<<x)
#define ld long double
#define __builtin_popcount __builtin_popcountll
#define pll pair<ll,ll>
template<class T1,class T2>
bool maximize(T1 &x,const T2 &y)
{
    if(x<y)
    {
        x=y;
        return 1;
    }
    return 0;
}
template<class T1,class T2>
bool minimize(T1 &x,const T2 &y)
{
    if(x>y)
    {
        x=y;
        return 1;
    }
    return 0;
}
void online()
{
    std::ios_base::sync_with_stdio(0);
    cin.tie(0);
//    #ifndef ONLINE_JUDGE
//    freopen("input.INP","r",stdin);
//    freopen("output.OUT","w",stdout);
//    #endif // ONLINE_JUDGE
}
const ll N=1e7+10,M=1e9+7;
ll a[N],b[N],n;
int main()
{
    online();
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        b[i]=1;
        while(a[i]%2==0) b[i]*=2,a[i]/=2;
        b[i]+=b[i-1];
    }
    ll q;
    cin>>q;
    while(q--)
    {
        ll x;
        cin>>x;
        ll base=0,d=n/2+1;
        while(d)
        {
            while(base+d<=n&&b[base+d]<x) base+=d;
            d/=2;
        }
        base++;
        cout<<a[base]<<'\n';
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 16 ms 3924 KB Output is correct
4 Correct 26 ms 2268 KB Output is correct
5 Correct 44 ms 5496 KB Output is correct
6 Correct 32 ms 4048 KB Output is correct
7 Correct 44 ms 5580 KB Output is correct
8 Correct 44 ms 5676 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 328 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 0 ms 340 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 16 ms 3924 KB Output is correct
4 Correct 26 ms 2268 KB Output is correct
5 Correct 44 ms 5496 KB Output is correct
6 Correct 32 ms 4048 KB Output is correct
7 Correct 44 ms 5580 KB Output is correct
8 Correct 44 ms 5676 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 328 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 0 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 0 ms 340 KB Output is correct
22 Correct 1 ms 344 KB Output is correct
23 Correct 25 ms 3052 KB Output is correct
24 Correct 30 ms 5152 KB Output is correct
25 Correct 57 ms 8740 KB Output is correct
26 Correct 37 ms 5580 KB Output is correct
27 Correct 34 ms 5484 KB Output is correct
28 Correct 65 ms 9192 KB Output is correct
29 Correct 76 ms 8708 KB Output is correct
30 Correct 34 ms 3692 KB Output is correct
31 Correct 64 ms 9140 KB Output is correct