Submission #855197

#TimeUsernameProblemLanguageResultExecution timeMemory
855197ancuber1031Intercastellar (JOI22_ho_t1)C++14
0 / 100
15 ms10644 KiB
#pragma GCC optimize("Ofast") #include <bits/stdc++.h> using namespace std; #define int long long #define pii pair<int,int> #define p_q priority_queue #define endl '\n' #define pb push_back signed main() { ios::sync_with_stdio(0), cin.tie(0), cout.tie(0); int n; cin>>n; vector<int> a(n); deque<int> ans, ps; for (auto& i : a) cin>>i; while(!a.empty()) { int cur = a.back(), cnt = 1; a.pop_back(); while(cur&1^1) { cur >>= 1; cnt <<= 1; } ans.push_front(cur); ps.push_front(cnt); } for (int i = 1; i < ps.size(); ++i) ps[i] += ps[i-1]; int q; cin>>q; while(q--) { int x; cin>>x; int l = -1, r = ps.back(); while(r-l > 1) { int mid = (l+r)>>1; if (ps[mid] < x) l = mid; else r = mid; } cout<<ans[r]<<endl; } return 0; }

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:21:18: warning: suggest parentheses around arithmetic in operand of '^' [-Wparentheses]
   21 |         while(cur&1^1) {
      |               ~~~^~
Main.cpp:28:23: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::deque<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |     for (int i = 1; i < ps.size(); ++i) ps[i] += ps[i-1];
      |                     ~~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...