Submission #780480

# Submission time Handle Problem Language Result Execution time Memory
780480 2023-07-12T09:21:17 Z anton Intercastellar (JOI22_ho_t1) C++17
100 / 100
399 ms 10680 KB
#include<bits/stdc++.h>

using namespace std;
#define int long long


vector<int> a;
vector<int> f;
vector<int> s;
signed main(){
    int n;
    cin>>n;
    a.resize(n);
    s.resize(n);
    f.resize(n);

    for(int i = 0; i<n; i++){
        cin>>a[i];
        f[i] = a[i];
        s[i] = 1LL;
        
        while(f[i]%2 ==0){
            f[i] = f[i]/2LL;
            s[i] = s[i]*2LL;
        }
        if(i!=0){
            s[i]+=s[i-1];
        }
    }

    int q;
    cin>>q;

    for(int i = 0; i<q; i++){
        int x;
        cin>>x;
        int id= 0;

        if(s[0]>=x){
            cout<<f[0]<<endl;
            continue;
        }
        for(int step = (1LL<<20LL); step>=1; step/=2LL){
            if(id+ step<n){
                if(s[id+step]<x){
                    id+=step;
                }
            }
        }

        cout<<f[id+1]<<endl;

    }


}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 76 ms 5484 KB Output is correct
4 Correct 199 ms 2612 KB Output is correct
5 Correct 294 ms 7020 KB Output is correct
6 Correct 144 ms 5324 KB Output is correct
7 Correct 298 ms 7116 KB Output is correct
8 Correct 292 ms 7212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 296 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 308 KB Output is correct
8 Correct 2 ms 340 KB Output is correct
9 Correct 1 ms 296 KB Output is correct
10 Correct 1 ms 300 KB Output is correct
11 Correct 2 ms 308 KB Output is correct
12 Correct 2 ms 340 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 2 ms 352 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 76 ms 5484 KB Output is correct
4 Correct 199 ms 2612 KB Output is correct
5 Correct 294 ms 7020 KB Output is correct
6 Correct 144 ms 5324 KB Output is correct
7 Correct 298 ms 7116 KB Output is correct
8 Correct 292 ms 7212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 296 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 308 KB Output is correct
16 Correct 2 ms 340 KB Output is correct
17 Correct 1 ms 296 KB Output is correct
18 Correct 1 ms 300 KB Output is correct
19 Correct 2 ms 308 KB Output is correct
20 Correct 2 ms 340 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 2 ms 352 KB Output is correct
23 Correct 168 ms 3192 KB Output is correct
24 Correct 153 ms 6320 KB Output is correct
25 Correct 344 ms 10404 KB Output is correct
26 Correct 196 ms 6476 KB Output is correct
27 Correct 172 ms 6636 KB Output is correct
28 Correct 367 ms 10680 KB Output is correct
29 Correct 399 ms 10240 KB Output is correct
30 Correct 241 ms 3916 KB Output is correct
31 Correct 357 ms 10600 KB Output is correct