이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |