Submission #534073

#TimeUsernameProblemLanguageResultExecution timeMemory
534073LittleOrangeIntercastellar (JOI22_ho_t1)C++17
100 / 100
72 ms6836 KiB
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    ios::sync_with_stdio(0);cin.tie(0);
    int n;
    cin >> n;
    vector<ll> a(n,0);
    for (int i = 0;i<n;i++){
        cin >> a[i];
    }
    vector<pair<ll,ll> > dat(n+1);
    dat[0] = {0,0};
    for (int i = 0;i<n;i++){
        ll v = a[i];
        ll c = 1;
        while (v&1^1){
            v>>=1;
            c<<=1;
        }
        dat[i+1] = {dat[i].first+c,v};
    }
    int q;
    cin >> q;
    while (q--){
        ll x;
        cin >> x;
        cout << (*lower_bound(dat.begin(),dat.end(),make_pair(x,0LL))).second << "\n";
    }
}

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:17:17: warning: suggest parentheses around arithmetic in operand of '^' [-Wparentheses]
   17 |         while (v&1^1){
      |                ~^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...