Submission #538646

# Submission time Handle Problem Language Result Execution time Memory
538646 2022-03-17T10:57:29 Z Harry464 Intercastellar (JOI22_ho_t1) C++14
100 / 100
523 ms 5376 KB
#include <cmath>
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

typedef long long ll;

int main(){

    ll n;
    cin >> n;

    vector <ll> a(n);

    for (int i = 0; i < n; i++)
        cin >> a[i];

    vector <ll> prefsum(1,0);
    for (int i = 0; i < n; i++){

        ll stependv = 1;
        while (a[i]%(stependv*2) == 0)
         stependv *= 2;
        
        a[i]/= stependv;
        prefsum.push_back(prefsum[i] + stependv);

    }

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

        ll x;
        cin >> x;

        ll l = 1, r = n; 

        while (l < r){

            ll mid = (l+r)/2;
            if (prefsum[mid] < x)
              l = mid + 1;
            else
              r = mid;

        }

        cout << a[l-1] << endl;


    }

}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 100 ms 3932 KB Output is correct
4 Correct 281 ms 1540 KB Output is correct
5 Correct 377 ms 4032 KB Output is correct
6 Correct 183 ms 3780 KB Output is correct
7 Correct 369 ms 4028 KB Output is correct
8 Correct 362 ms 4020 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 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 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 2 ms 212 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 300 KB Output is correct
12 Correct 3 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 3 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 100 ms 3932 KB Output is correct
4 Correct 281 ms 1540 KB Output is correct
5 Correct 377 ms 4032 KB Output is correct
6 Correct 183 ms 3780 KB Output is correct
7 Correct 369 ms 4028 KB Output is correct
8 Correct 362 ms 4020 KB Output is correct
9 Correct 0 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 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 2 ms 212 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 300 KB Output is correct
20 Correct 3 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 3 ms 212 KB Output is correct
23 Correct 228 ms 1996 KB Output is correct
24 Correct 198 ms 3568 KB Output is correct
25 Correct 454 ms 5376 KB Output is correct
26 Correct 290 ms 2908 KB Output is correct
27 Correct 236 ms 3588 KB Output is correct
28 Correct 468 ms 4704 KB Output is correct
29 Correct 523 ms 4012 KB Output is correct
30 Correct 303 ms 1516 KB Output is correct
31 Correct 489 ms 4620 KB Output is correct