답안 #871005

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
871005 2023-11-09T17:01:35 Z Trisanu_Das Seesaw (JOI22_seesaw) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;

int n;
double a[200005], pref[200005], dp[200005][200005];
 
double chk(double L){
	for(int i = 0; i <= n; i++) for(int j = 0; j <= n; j++) dp[i][j] = INT_MAX;
	for(int i = 0; i < n; i++) if(a[i] >= L) dp[i][i] = a[i];
	for(int l = 2; l <= n; l++){
		for(int i = 0; i + l - 1 < n; i++){
			int j = i + l - 1;
			if(pref[j + 1] - pref[i] < L * (j - i + 1)) continue;
			dp[i][j] = (pref[j + 1] - pref[i])/(j - i + 1);
			dp[i][j] = max(dp[i][j], min(dp[i + 1][j], dp[i][j - 1]));
		}
	}
	return dp[0][n - 1];
}
 
int main() {
	cin >> n;
	for(int i = 0; i < n; i++) cin >> a[i];
	sort(a, a + n); double ans = a[n - 1] - a[0];
	for(int i = 0; i < n; i++) pref[i + 1] = pref[i] + a[i];
	for(int i = 0; i < n; i++){
		for(int j = i; j < n; j++){
			double L = (pref[j + 1] - pref[i]) / (j - i + 1);
			ans = min(ans, chk(L) - L);
		}
	}
	cout << fixed << setprecision(9) << ans << '\n';
}

Compilation message

/usr/bin/ld: failed to convert GOTPCREL relocation; relink with --no-relax
collect2: error: ld returned 1 exit status