Submission #873759

#TimeUsernameProblemLanguageResultExecution timeMemory
873759AlexIntercastellar (JOI22_ho_t1)C++14
100 / 100
139 ms31420 KiB
#include <bits/stdc++.h> #define int long long using namespace std; int Dos(int n) { return (n & (~(n - 1))); } int32_t main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin >> n; map<int,int>m; vector<int>v; map<int,int>m2; int cont = 0; for(int i = 0 ; i < n ; i++){ int a; cin >> a; if(!(a & 1)){ int l = Dos(a); cont += l - 1; v.push_back(cont); if(l == a){ m[cont] = 1; } else m[cont] = a / l; } else m[cont] = a; cont++; } int ms ; cin >> ms; for(int i = 0 ; i < ms ; i++){ int k ; cin >> k; if(m[k - 1] != 0){ cout << m[k - 1] << "\n"; } else{ vector<int>::iterator low; low = lower_bound(v.begin() , v.end() , k -1); cout << m[*low] << "\n"; } } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...