Submission #1264252

#TimeUsernameProblemLanguageResultExecution timeMemory
1264252wedonttalkanymoreIntercastellar (JOI22_ho_t1)C++20
100 / 100
46 ms7120 KiB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

#define int long long
#define pii pair<ll, ll>
#define fi first
#define se second

const ll N = 2e5 + 5, inf = 1e18, mod = 1e9 + 7, block = 320, lim = 16;

int n, a[N];
int q;
int pfs[N], val[N];

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    if (fopen(".inp", "r")) {
        freopen(".inp", "r", stdin);
        freopen(".out", "w", stdout);
    }
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i];
    for (int i = 1; i <= n; i++) {
        int t = a[i], res = 0;
        while(t > 0 && t % 2 == 0) {
            res++;
            t /= 2;
        }
        pfs[i] = pfs[i - 1] + (1 << res);
        val[i] = a[i] / (1 << res);
    }
    cin >> q;
    while(q-- > 0) {
        int x;
        cin >> x;
        auto it = lower_bound(pfs + 1, pfs + n + 1, x) - pfs;
        cout << val[it] << '\n';
    }
    return 0;
}

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:20:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   20 |         freopen(".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~
Main.cpp:21:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   21 |         freopen(".out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...