Submission #617192

# Submission time Handle Problem Language Result Execution time Memory
617192 2022-08-01T09:30:26 Z GoodkNight Intercastellar (JOI22_ho_t1) C++17
25 / 100
372 ms 4028 KB
#include<iostream>
using namespace std;
unsigned int ciasta[200008][2];
int binsearch(unsigned int 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(){
    unsigned int 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;
    unsigned int x;
    for(int i=0; i<q; i++){
        cin >> x;
        cout << ciasta[binsearch(x, n)][1]<<"\n";
    }
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:33:19: warning: comparison of integer expressions of different signedness: 'int' and 'unsigned int' [-Wsign-compare]
   33 |     for(int i=0; i<n; i++){
      |                  ~^~
Main.cpp:38:19: warning: comparison of integer expressions of different signedness: 'int' and 'unsigned int' [-Wsign-compare]
   38 |     for(int i=1; i<n; i++){
      |                  ~^~
Main.cpp:43:19: warning: comparison of integer expressions of different signedness: 'int' and 'unsigned int' [-Wsign-compare]
   43 |     for(int i=0; i<q; i++){
      |                  ~^~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 304 KB Output is correct
3 Correct 126 ms 2484 KB Output is correct
4 Correct 246 ms 1960 KB Output is correct
5 Correct 372 ms 3900 KB Output is correct
6 Correct 200 ms 2716 KB Output is correct
7 Correct 353 ms 3976 KB Output is correct
8 Correct 343 ms 4028 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 308 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 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 2 ms 312 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 2 ms 316 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Incorrect 1 ms 316 KB Output isn't correct
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 304 KB Output is correct
3 Correct 126 ms 2484 KB Output is correct
4 Correct 246 ms 1960 KB Output is correct
5 Correct 372 ms 3900 KB Output is correct
6 Correct 200 ms 2716 KB Output is correct
7 Correct 353 ms 3976 KB Output is correct
8 Correct 343 ms 4028 KB Output is correct
9 Correct 1 ms 308 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 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 2 ms 312 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 2 ms 316 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Incorrect 1 ms 316 KB Output isn't correct
19 Halted 0 ms 0 KB -