Submission #648846

# Submission time Handle Problem Language Result Execution time Memory
648846 2022-10-08T13:50:59 Z GoodkNight Intercastellar (JOI22_ho_t1) C++17
100 / 100
453 ms 9148 KB
#include<iostream>
using namespace std;
long long ciasta[200008][2];
int binsearch(long long x, int n){
    int p=0; int k = n-1;
    while(p!=k){
        int mid=(p+k)/2;
        if(ciasta[mid][0]==x){
            return (mid);
        }
        else{
            if(ciasta[mid][0]>x){
                k = mid;
            }
            else{
                p=mid+1;
            }
        }
    }
    return(k);
}
void dwoj(int a, int i){
    unsigned int odp=1;
    while(a%2==0){
        odp=odp*2;
        a=a/2;
    }
    ciasta[i][0]=odp;
    ciasta[i][1]=a;
}
int main(){
    long long n, q, a; cin >> n;
    for(int i=0; i<n; i++){
        cin >> a;
        dwoj(a, i);
    }

    for(int i=1; i<n; i++){
        ciasta[i][0]+=ciasta[i-1][0];
    }
    cin >> q;
    long long x;
    for(int i=0; i<q; i++){
        cin >> x;
        cout << ciasta[binsearch(x, n)][1]<<"\n";
    }
}
# 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 90 ms 3956 KB Output is correct
4 Correct 251 ms 2256 KB Output is correct
5 Correct 346 ms 5500 KB Output is correct
6 Correct 184 ms 3956 KB Output is correct
7 Correct 346 ms 5540 KB Output is correct
8 Correct 351 ms 5760 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 0 ms 212 KB Output is correct
4 Correct 1 ms 308 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 3 ms 320 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 3 ms 340 KB Output is correct
12 Correct 3 ms 340 KB Output is correct
13 Correct 1 ms 316 KB Output is correct
14 Correct 3 ms 320 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 90 ms 3956 KB Output is correct
4 Correct 251 ms 2256 KB Output is correct
5 Correct 346 ms 5500 KB Output is correct
6 Correct 184 ms 3956 KB Output is correct
7 Correct 346 ms 5540 KB Output is correct
8 Correct 351 ms 5760 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 308 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 3 ms 320 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 3 ms 340 KB Output is correct
20 Correct 3 ms 340 KB Output is correct
21 Correct 1 ms 316 KB Output is correct
22 Correct 3 ms 320 KB Output is correct
23 Correct 212 ms 2984 KB Output is correct
24 Correct 192 ms 5208 KB Output is correct
25 Correct 417 ms 8824 KB Output is correct
26 Correct 247 ms 5488 KB Output is correct
27 Correct 210 ms 5452 KB Output is correct
28 Correct 445 ms 9148 KB Output is correct
29 Correct 444 ms 8744 KB Output is correct
30 Correct 291 ms 3700 KB Output is correct
31 Correct 453 ms 9076 KB Output is correct