Submission #681853

#TimeUsernameProblemLanguageResultExecution timeMemory
681853peijarIntercastellar (JOI22_ho_t1)C++17
100 / 100
84 ms9344 KiB
#include <bits/stdc++.h>
#define int long long
using namespace std;

string to_string(string s) { return s; }
template <typename T> string to_string(T v) {
  bool first = true;
  string res = "[";
  for (const auto &x : v) {
    if (!first)
      res += ", ";
    first = false;
    res += to_string(x);
  }
  res += "]";
  return res;
}

void dbg_out() { cout << endl; }
template <typename Head, typename... Tail> void dbg_out(Head H, Tail... T) {
  cout << ' ' << to_string(H);
  dbg_out(T...);
}

#ifdef DEBUG
#define dbg(...) cout << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
#else
#define dbg(...)
#endif

signed main(void) {
  ios_base::sync_with_stdio(false);
  cin.tie(0);

  int N;
  cin >> N;
  vector<pair<int, int>> elements;
  for (int i = 0; i < N; ++i) {
    int A;
    cin >> A;
    int cnt = 1;
    while (A % 2 == 0)
      cnt *= 2, A /= 2;
    if (!elements.empty())
      cnt += elements.back().first;
    elements.emplace_back(cnt, A);
    dbg(cnt);
  }

  int Q;
  cin >> Q;
  while (Q--) {
    int id;
    cin >> id;
    int pos = lower_bound(elements.begin(), elements.end(), pair(id, 0LL)) -
              elements.begin();
    cout << elements[pos].second << '\n';
  }
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...