답안 #1005663

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1005663 2024-06-22T17:32:12 Z MarwenElarbi Intercastellar (JOI22_ho_t1) C++17
100 / 100
259 ms 10736 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#define fi first
#define se second
#define ll long long
#define pb push_back
#define ii pair<int,int>
template <class T>
using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
const int nax=2e3+5;
#define optimise ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
int main()
{
    optimise;   
    int n;
    cin>>n;
    pair<long long,long long> tab[n];
    for (int i = 0; i < n; ++i)
    {
        int x;
        int cnt=1;
        cin>>x;
        while(x%2==0){
            cnt*=2;
            x/=2;
        }
        tab[i]={cnt,x};
    }
    long long pre[n];
    pre[0]=tab[0].fi;
    for (int i = 1; i < n; ++i)
    {
        pre[i]=tab[i].fi+pre[i-1];
    }
    int q;
    cin>>q;
    while(q--){
        long long x;
        cin>>x;
        int l=-1;
        int r=n-1;
        while(r-l>1){
            int mid=(r+l)/2;
            if(pre[mid]>=x) r=mid;
            else l=mid;
        }
        cout << tab[r].se<<endl;
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 70 ms 4988 KB Output is correct
4 Correct 169 ms 1852 KB Output is correct
5 Correct 224 ms 5456 KB Output is correct
6 Correct 111 ms 4420 KB Output is correct
7 Correct 239 ms 5412 KB Output is correct
8 Correct 220 ms 5456 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 400 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 2 ms 348 KB Output is correct
12 Correct 2 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 468 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 70 ms 4988 KB Output is correct
4 Correct 169 ms 1852 KB Output is correct
5 Correct 224 ms 5456 KB Output is correct
6 Correct 111 ms 4420 KB Output is correct
7 Correct 239 ms 5412 KB Output is correct
8 Correct 220 ms 5456 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 400 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 2 ms 348 KB Output is correct
20 Correct 2 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 1 ms 468 KB Output is correct
23 Correct 136 ms 3400 KB Output is correct
24 Correct 107 ms 6276 KB Output is correct
25 Correct 247 ms 10364 KB Output is correct
26 Correct 133 ms 6512 KB Output is correct
27 Correct 111 ms 6768 KB Output is correct
28 Correct 247 ms 10736 KB Output is correct
29 Correct 243 ms 10324 KB Output is correct
30 Correct 174 ms 3924 KB Output is correct
31 Correct 259 ms 10720 KB Output is correct