제출 #744644

#제출 시각아이디문제언어결과실행 시간메모리
744644oolimryArchery (IOI09_archery)C++17
26 / 100
2093 ms12796 KiB
#include <bits/stdc++.h>
using namespace std;
#define sz(x) (int) (x).size()
#define all(x) (x).begin(), (x).end()
#define show(x) cerr << #x << " is " << x << endl;
#define show2(x,y) cerr << #x << " is " << x << " " << #y << " is " << y << endl;
#define show3(x,y,z) cerr << #x << " is " << x << " " << #y << " is " << y << " " << #z << " is " << z << endl;
typedef long long lint;
typedef pair<lint,lint> ii;

int arr[400005];
int target[400005];
int n, R; 
int me;

int solve(int s){
	target[me] = s;
	for(int i = 1;i <= 2*n;i++){
		int newi = i + (i >= 2*s);
		target[arr[i]] = (newi+1)/2;
	}
	
	//for(int i = 1;i <= 2*n;i++) show2(i, target[i]);
	
	if(me >= n+2){ ///weak
		set<int> available;
		for(int i = 2;i <= n;i++) available.insert(i);
		
		for(int i = 2*n;i >= me;i--){
			auto it = available.upper_bound(target[i]);
			
			if(it == available.begin()) it = --available.end();
			else it--;
						
			if(i == me) return *it;
			available.erase(it);
		}
	}
	else{ ///strong
		assert(false);
	}
}


int main(){
	ios_base::sync_with_stdio(false); cin.tie(0);
	
	cin >> n >> R;
	cin >> me;
	
	if(me == 1){
		cout << n;
		return 0;
	}
	
	for(int i = 1;i <= 2*n-1;i++) cin >> arr[i];
	

	
	int bestPos = -1;
	int bestVal = n;

	for(int t = 1;t <= n;t++){
		int res = solve(t);
		if(res <= bestVal){
			bestVal = res;
			bestPos = t; 
		}
	}
	
	cout << bestPos;
}

컴파일 시 표준 에러 (stderr) 메시지

archery.cpp: In function 'int solve(int)':
archery.cpp:42:1: warning: control reaches end of non-void function [-Wreturn-type]
   42 | }
      | ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...