Submission #884458

#TimeUsernameProblemLanguageResultExecution timeMemory
884458EJIC_B_KEDAXIntercastellar (JOI22_ho_t1)C++14
100 / 100
71 ms10836 KiB
#ifdef LOCAL //#define _GLIBCXX_DEBUG #endif #include <bits/stdc++.h> #include <random> #ifndef LOCAL //#pragma GCC optimize("O3") //#pragma GCC optimize("Ofast") //#pragma GCC optimize("unroll-loops") #pragma GCC target("avx,avx2,bmi,bmi2,popcnt,lzcnt") #endif using namespace std; using ll = long long; using ld = long double; #define x first #define y second #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(), x.rend() mt19937_64 mt(418); void solve(); void init(); int32_t main() { #ifndef LOCAL cin.tie(nullptr)->sync_with_stdio(false); #else freopen("input.txt", "r", stdin); #endif // srand(time(0)); init(); cout << fixed << setprecision(20); int t = 1; // cin >> t; while (t--) { solve(); } } void init() {} void solve() { int n; cin >> n; vector<ll> a(n), b(n, 1), pref(n + 1, 0); for (int i = 0; i < n; i++) { cin >> a[i]; while (~a[i] & 1) { b[i] <<= 1; a[i] >>= 1; } } for (int i = 0; i < n; i++) { pref[i + 1] = pref[i] + b[i]; } int q; cin >> q; while (q--) { ll x; cin >> x; int l = -1, r = n + 1; while (r - l > 1) { int m = (r + l) / 2; if (pref[m] >= x) { r = m; } else { l = m; } } cout << a[l] << '\n'; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...