Submission #1296514

#TimeUsernameProblemLanguageResultExecution timeMemory
1296514muhammad-ahmadIntercastellar (JOI22_ho_t1)C++20
100 / 100
197 ms6872 KiB
// #include <bits/stdc++.h> #include <iostream> #include <cmath> #include <algorithm> #include <map> #include <vector> #include <iomanip> #include <string> #include <queue> #include <set> #include <deque> #include <numeric> #include <stack> #include <chrono> using namespace std; void fast_io(){ // freopen("", "r", stdin); // freopen("", "w", stdout); ios::sync_with_stdio(0); cin.tie(); cout.tie(); cout << setprecision(9); } #define int long long #define endl '\n' #define all(v) (v).begin(), (v).end() #define rall(v) (v).rbegin(), (v).rend() #define fi first #define se second void solve() { int n; cin >> n; int a[n + 1]; for (int i = 1; i <= n; i++) cin >> a[i]; int pref[n + 1] = {}, C[n + 1] = {}; for (int i = 1; i <= n; i++){ int c = 1; while (a[i] % 2 == 0){ c *= 2; a[i] /= 2; } pref[i] = pref[i - 1] + c; C[i] = a[i]; } int q; cin >> q; for (int Q = 1; Q <= q; Q++){ int x; cin >> x; int l = 0, r = n; while (r - l > 1){ int m = (l + r) / 2; if (pref[m] < x) l = m; else r = m; } cout << C[r] << endl; } return; } // 7 7 9 2 2 2 1 1 1 1 1 1 1 1 3 3 3 3 signed main() { fast_io(); srand(chrono::steady_clock::now().time_since_epoch().count()); int tc = 1; // cin >> tc; while (tc--) solve(); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...