제출 #846450

#제출 시각아이디문제언어결과실행 시간메모리
846450vjudge1OGLEDALA (COI15_ogledala)C++17
41 / 100
2490 ms524288 KiB
#include <bits/stdc++.h>
#define fast cin.tie(0)->sync_with_stdio(0);
#define int long long
#define inf ((int)1e18)
#define N 300005
using namespace std;
int arr[N];

int32_t main(){
	fast
	int m, n, q;
	cin>>m>>n>>q;
	multiset <pair<int, int> > st; // başlangıç indexi ve uzunluk

	int prev = 0;
	for(int i = 0; i < n; i++) {
		cin>>arr[i];
		st.insert({-(arr[i] - prev - 1), prev + 1});
		prev = arr[i];
	}
	st.insert({-(m - prev), prev + 1});

	int pushed = n;
	int len, l, mid;
	while(q--) {
		int b;
		cin>>b;
		if(b <= n) {
			mid = arr[b - 1];
		}
		while(pushed < b) {
			pair<int, int> it = *(st.begin());
			st.erase(st.begin());
			len = -(it.first), l = it.second;
			mid = l - 1 + (len + 1) / 2;
			st.insert({-(mid - l), l});
			st.insert({-(mid - l + !(len % 2)), mid + 1});
			// cout<<(mid-l)<<" "<<l<<" | "<<(mid - l + !(len % 2))<<" "<<(mid + 1)<<"\n";
			pushed++;
		}
		cout<<mid<<"\n";
	}
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...