Submission #938604

#TimeUsernameProblemLanguageResultExecution timeMemory
938604vjudge1Intercastellar (JOI22_ho_t1)C++17
25 / 100
48 ms3156 KiB
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin >> n; vector<int> v(n); for (int i = 0; i < n; i++) cin >> v[i]; vector<int> sums(n); for (int i = 0; i < n; i++) { int temp = v[i]; int cnt = 0; while (temp%2==0) { temp/=2; cnt++; } sums[i] = cnt; } vector<int> pref_sum(n,0); pref_sum[0] = (1<<sums[0]); for (int i = 1; i < n; i++) pref_sum[i] = pref_sum[i-1]+(1<<sums[i]); int q; cin >> q; while(q--) { int x; cin >> x; int l = 0, r = n-1; while (r-l>1) { int mid = l+r>>1; if (pref_sum[mid] <= x) l = mid; else r = mid; } if (pref_sum[l] >= x) cout << v[l]/(1<<(sums[l])) << '\n'; else cout << v[r]/(1<<(sums[r])) << '\n'; } return 0; }

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:40:24: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   40 |             int mid = l+r>>1;
      |                       ~^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...