Submission #801085

#TimeUsernameProblemLanguageResultExecution timeMemory
801085vjudge1Intercastellar (JOI22_ho_t1)C++17
100 / 100
68 ms5324 KiB
#ifdef Home
#define _GLIBCXX_DEBUG
#endif // Home

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;

main() {
#ifdef Home
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif // Home
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    ll n, q, x, y, l, r, m;
    cin >> n;
    ll pref[n + 1], num[n + 1];
    pref[0] = num[0] = 0;
    for(int i = 1; i <= n; ++ i) {
        cin >> x;
        y = __builtin_ctz(x);
        pref[i] = pref[i - 1] + (1<<y);
        num[i] =(x>>y);
    }
    for(cin >> q; q --> 0;) {
        cin >> x;
        l = 0, r = n;
        for(; l + 1 < r;) {
            m = (l + r) / 2;
            (pref[m] < x ? l : r) = m;
        }
        cout << num[r] << '\n';
    }
}

Compilation message (stderr)

Main.cpp:12:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   12 | main() {
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...