Submission #915296

#TimeUsernameProblemLanguageResultExecution timeMemory
915296HorizonWestIntercastellar (JOI22_ho_t1)C++17
100 / 100
80 ms9300 KiB
#include <bits/stdc++.h> using namespace std; #define endl '\n' #define db double #define int long long #define pb push_back #define fs first #define sd second #define Mod long(1e9 + 7) #define all(x) x.begin(), x.end() #define unvisited long(-1) #define Eps double(1e-9) #define _for(i, n) for(int i = 0; i < (n); i++) #define dbg(x) cout << #x ": " << x << endl; const int Max = 1e6 + 7, Inf = 1e9 + 7; void print(bool x) { cout << (x ? "Yes" : "No") << endl; } void solve() { int n; cin >> n; vector <pair<int, int>> p(n + 1, {0, 1}); for(int i = 0; i < n; i++) { cin >> p[i].fs; while(p[i].fs % 2 == 0) { p[i].fs /= 2; p[i].sd *= 2; } } p[n].sd = long(1e15); for(int i = 1; i <= n; i++) p[i].sd += p[i - 1].sd; int q; cin >> q; while(q--) { int x; cin >> x; int a = -1, b = n; while(abs(a - b) != 1) { int c = (a + b) / 2; if(p[c].sd >= x) b = c; else a = c; } cout << p[b].fs << endl; } } int32_t main() { ios_base::sync_with_stdio(0); cin.tie(0); int Q = 1; //cin >> Q; while(Q--) { solve(); } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...