제출 #846388

#제출 시각아이디문제언어결과실행 시간메모리
846388vjudge1OGLEDALA (COI15_ogledala)C++17
41 / 100
213 ms16308 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...