Submission #618819

#TimeUsernameProblemLanguageResultExecution timeMemory
618819HappyPacManOGLEDALA (COI15_ogledala)C++14
41 / 100
2563 ms524288 KiB
#include <bits/stdc++.h> #define int long long using namespace std; int32_t main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); int M,N,Q; cin >> M >> N >> Q; vector<int> vec; vec.push_back(0); for(int i=0;i<N;i++){ int Ai; cin >> Ai; vec.push_back(Ai); } vec.push_back(M+1); priority_queue<pair<int,int> > pq; for(int i=1;i<vec.size();i++){ pq.emplace(vec[i]-vec[i-1],-vec[i-1]); } int curr = N+1; while(Q--){ int Bi; cin >> Bi; if(Bi <= N){ cout << vec[Bi] << "\n"; }else{ while(curr < Bi){ auto [u,v] = pq.top(); pq.pop(); int lw = u/2; int hg = (u+1)/2; pq.emplace(lw,v); pq.emplace(hg,v-lw); curr++; } auto [u,v] = pq.top(); cout << -v+u/2 << "\n"; } } }

Compilation message (stderr)

ogledala.cpp: In function 'int32_t main()':
ogledala.cpp:20:15: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |  for(int i=1;i<vec.size();i++){
      |              ~^~~~~~~~~~~
ogledala.cpp:31:10: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   31 |     auto [u,v] = pq.top();
      |          ^
ogledala.cpp:39:9: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   39 |    auto [u,v] = pq.top();
      |         ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...