Submission #800248

#TimeUsernameProblemLanguageResultExecution timeMemory
800248caganyanmazIntercastellar (JOI22_ho_t1)C++17
100 / 100
422 ms10700 KiB
#include <bits/stdc++.h> #define int int64_t using namespace std; constexpr static int MXSIZE = 2e5; int v[MXSIZE], prefix[MXSIZE+1], f[MXSIZE]; int32_t main() { int n; cin >> n; for (int i = 0; i < n; i++) cin >> v[i]; for (int i = 0; i < n; i++) { f[i] = v[i]; int c = 1; while (!(f[i]&1)) { c <<= 1; f[i] >>= 1; } prefix[i+1] = c; } for (int i = 1; i <= n; i++) prefix[i] += prefix[i-1]; int q; cin >> q; while (q--) { int qq; cin >> qq; int l = 0, r = n+1; while (r - l > 1) { int m = l+r>>1; if (prefix[m] >= qq) r = m; else l = m; } cout << f[l] << "\n"; } }

Compilation message (stderr)

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