Submission #710772

#TimeUsernameProblemLanguageResultExecution timeMemory
710772mdubIntercastellar (JOI22_ho_t1)C++14
100 / 100
525 ms20244 KiB
#include <bits/stdc++.h>

using namespace std;

int main () {
  int n; cin >> n;
  vector<long long> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  set<pair<long long, long long>> s;
  long long pos = 0;
  for (auto elem: a) {
    int count = 1; 
    
    while (elem % 2 == 0) {
      count *= 2;
      elem /= 2;
    }
    s.insert({pos, elem});
    pos += count;
  }
  int q; cin >> q;
  for (int i = 0; i < q; i++) {
    long long query; cin >> query;
    query--;
    auto it = (s.upper_bound({query, 1e18}));
    it--;
    cout << (*it).second << '\n';
  }
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...