Submission #1018583

#TimeUsernameProblemLanguageResultExecution timeMemory
1018583toast12Intercastellar (JOI22_ho_t1)C++14
100 / 100
57 ms9420 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long ll divide(ll x) { ll res = 1; if (x % 2 == 0) res = 2*divide(x/2); return res; } int main() { ios_base::sync_with_stdio(0); cin.tie(NULL); int n; cin >> n; vector<ll> nums(n); for (int i = 0; i < n; i++) { cin >> nums[i]; } vector<ll> ps; ll prev = 0; for (int i = 0; i < n; i++) { ps.push_back(prev+divide(nums[i])); prev = ps.back(); } int q; cin >> q; while (q--) { ll x; cin >> x; auto it = lower_bound(ps.begin(), ps.end(), x); int idx = it-ps.begin(); ll sz = nums[idx]; while (sz % 2 == 0) sz /= 2; cout << sz << '\n'; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...