이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define min(x,y) (x>=y?y:x)
#define max(x,y) ((x)>=(y)?(x):(y))
#define xc3(x) (x*(x-1)*(x-2)/6)
#define xc2(x) (x*(x-1)/2)
#define GF G[node][i].first
#define tll tuple<ll,ll,ll>
#define pq1 (get<0>(pq.top()))
#define pq2 (get<1>(pq.top()))
#define pq3 (get<2>(pq.top()))
#define K ((A-1)/2)
using namespace std;
#define ll long long
#define ull unsigned long long
int main()
{
ll N,M,Q;cin>>M>>N>>Q;
//priority_queue<tll,vector<tll>,greater<tll>>pq;
priority_queue<tll>pq;
vector<ll> AR(N,-1);
ll i=1;
for(ll j=0;j<N;j++){
ll bq;cin>>bq;
AR[j]=bq;
pq.push(make_tuple(bq-i,M-i,M-(bq-1)));
i=bq+1;
}
pq.push(make_tuple(M-i+1,M-i,0));
vector<int> qar(Q);for(int &x:qar)cin>>x;for(int &x:qar)x--;
int w=0;
while(qar[w]<N){
cout<<AR[qar[w]]<<endl;
w++;
}
// while(!pq.empty()){cout<<pq1<<" "<<pq2<<" "<<pq3<<endl;pq.pop();} PRINT THE QUEUE
for(int j=N;j<qar[qar.size()-1]+1;j++){
ll A=pq1,B=M-pq2,C=M-pq3;
pq.pop();
if(j==qar[w]){
cout<<B+K<<endl;w++;}
tuple<ll,ll,ll> tpl = make_tuple(K,M-B,M-(B+K-1));
pq.push(tpl);
tpl = make_tuple(A/2,M-(B+K+1),M-C);
pq.push(tpl);
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |