Submission #618781

#TimeUsernameProblemLanguageResultExecution timeMemory
618781Je_OOGLEDALA (COI15_ogledala)C++17
41 / 100
92 ms23176 KiB
#include<bits/stdc++.h> #define fi first #define se second #define mp make_pair #define pb push_back using namespace std; typedef long long ll; typedef pair<int, int> ii; typedef pair<ll, pair<ll, ll>> iii; const int N = 3e5 + 5; ll a[N], b[N], ans[N]; int main(){ ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); ll m, n, q; cin >> m >> n >> q; for(int i = 1; i <= n; ++i)cin >> a[i]; for(int i = 1; i <= q; ++i)cin >> b[i]; for(int i = 1; i <= n; ++i)ans[i] = a[i]; priority_queue<iii> pq; if(a[1] > 1)pq.push(mp(a[1] - 1, mp(-1, -(a[1] - 1)))); for(int i = 1; i < n; ++i){ if(a[i] + 1 < a[i + 1]){ pq.push(mp(a[i + 1] - a[i] - 1, mp(-(a[i] + 1), -(a[i + 1] - 1)))); } } if(a[n] < m)pq.push(mp(m - a[n], mp(-(a[n] + 1), -m))); for(int i = n + 1; i < N; ++i){ iii cur = pq.top(); pq.pop(); ans[i] = -cur.se.fi + (cur.fi - 1)/2; if(-cur.se.fi < ans[i]){ pq.push(mp(ans[i] - (-cur.se.fi), mp(cur.se.fi, -(ans[i] - 1)))); } if(ans[i] < -cur.se.se){ pq.push(mp(-cur.se.se - ans[i], mp(-(ans[i] + 1), cur.se.se))); } } for(int i = 1; i <= q; ++i){ cout << ans[b[i]] << '\n'; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...