답안 #618986

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
618986 2022-08-02T08:46:36 Z sentheta OGLEDALA (COI15_ogledala) C++17
19 / 100
243 ms 20280 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+1)){
		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 2 ms 212 KB Output is correct
2 Correct 2 ms 212 KB Output is correct
3 Correct 153 ms 3716 KB Output is correct
4 Correct 157 ms 3724 KB Output is correct
5 Correct 241 ms 11624 KB Output is correct
6 Correct 243 ms 10816 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 131 ms 20280 KB Output is correct
2 Correct 127 ms 20252 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 -