Submission #1000143

#TimeUsernameProblemLanguageResultExecution timeMemory
1000143THXuanIntercastellar (JOI22_ho_t1)C++14
25 / 100
36 ms5716 KiB
#include <iostream> #include <vector> #include <algorithm> #include <queue> #include <set> #include <map> #define INF 1e9 using namespace std; typedef long long ll; void solve() { int n; cin >> n; vector<ll>a(n + 1),s(n + 1); for (int i = 1; i <= n; i++) cin >> a[i]; for (int i = 1; i <= n; i++) { if (a[i] % 2 == 1) { s[i] = s[i - 1] + 1; } else { for (int j = 1; j <= 20; j++) { if ((a[i] / (1 << j)) % 2 == 1) { a[i] = a[i] / (1 << j); s[i] = s[i - 1] + (1 << j); break; } } } } int q; cin >> q; while (q--) { ll x; cin >> x; int lo = 1; int hi = n; while (lo < hi) { int mid = (lo + hi) / 2; if (s[mid] < x)lo = mid + 1; else hi = mid; } cout << a[lo] << "\n"; } } int main() { ios_base::sync_with_stdio(0); cin.tie(0); int t = 1;// cin>>t; while (t--) solve(); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...