Submission #1333192

#TimeUsernameProblemLanguageResultExecution timeMemory
1333192prunjuiceIntercastellar (JOI22_ho_t1)C++20
100 / 100
241 ms16224 KiB
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define MAX LLONG_MAX
#define MIN LLONG_MIN
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define pf push_front
const int mod = 1e9 + 7;
signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    int ans = 0;
    vector <int> v (n);
    map <int, int> mp;
    for (int i = 0; i < n; i++){
        cin >> v[i];
    }
    for (int i = 0; i < n; i++){
        int cnt = 1;
        while (v[i] % 2 != 1){
            v[i] /= 2;
            cnt *= 2;
        }
        ans += cnt;
        mp[ans] = v[i];
    }
    int q;
    cin >> q;
    for (int i = 0; i < q; i++){
        int x;
        cin >> x;
        auto it = mp.lb(x);
        cout << it->se << endl;
    }
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...