답안 #618984

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
618984 2022-08-02T08:45:54 Z sentheta OGLEDALA (COI15_ogledala) C++17
0 / 100
140 ms 20256 KB
#include<algorithm>
#include<iostream>
#include<cassert>
#include<vector>
#include<string>
#include<array>
#include<stack>
#include<queue>
#include<map>
#include<set>
using namespace std;

#define V vector
#define Int long long
#define rep(i,a,b) for(int i=(int)(a); i<(int)(b); i++)
#define nl '\n'
#define dbg(x) cout << "?" << #x << " : " << x << endl;
#define all(x) (x).begin(), (x).end()


const int N = 3e5+5;

int m, n, q;

// {len, -l, r}
set<array<int,3>> s;
void insert(int l,int r){
	s.insert({r-l+1, -l, r});
}

int ans[N];

signed main(){

	cin >> m >> n >> q;

	V<int> taken;
	rep(i,1,n+1){
		int x;
		cin >> x;

		ans[i] = x;
		taken.push_back(x);
	}
	
	sort(all(taken));
	if(1<taken[0]){
		insert(1,taken[0]-1);
	}
	if(taken.back()<m){
		insert(taken.back()+1,m);
	}
	rep(i,0,n-1){
		insert(taken[i]+1,taken[i+1]-1);
	}


	rep(i,n+1,min(N,m)){
		auto[len,l,r] = *prev(s.end());
		l *= -1;
		s.erase(prev(s.end()));

		int mid;
		if(len&1) mid = l+len/2;
		else mid = l+len/2-1;

		ans[i] = mid;

		if(l<mid) insert(l,mid-1);
		if(mid<r) insert(mid+1,r);
	}

	while(q--){
		int i;
		cin >> i;

		cout << ans[i] << nl;
	}

	
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 2 ms 212 KB Output is correct
3 Incorrect 140 ms 3788 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 117 ms 20252 KB Output is correct
2 Correct 118 ms 20256 KB Output is correct
3 Runtime error 1 ms 340 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 340 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -