답안 #899315

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
899315 2024-01-05T18:26:31 Z denniskim Seesaw (JOI22_seesaw) C++17
0 / 100
0 ms 348 KB
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef __int128 lll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pld;
#define MAX 9223372036854775807LL
#define MIN -9223372036854775807LL
#define INF 0x3f3f3f3f3f3f3f3f
#define fi first
#define se second
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cout << fixed; cout.precision(10);
#define sp << " "
#define en << "\n"
#define compress(v) sort(v.begin(), v.end()), v.erase(unique(v.begin(), v.end()), v.end())

ll n;
ll a[200010];
ld ans = INF;

int main(void)
{
	fastio
	
	cin >> n;
	
	for(ll i = 1 ; i <= n ; i++)
		cin >> a[i];
	
	for(ll i = 1 ; i <= n ; i++)
	{
		ld maxx = a[i], minn = a[i];
		ll s = i - 1, e = i + 1;
		ll sum = a[i];
		
		for(ll j = 2 ; j <= n ; j++)
		{
			if(s <= 0)
				sum += a[e++];
			else if(e > n)
				sum += a[s--];
			
			else
			{
				ld nxt1 = (ld)(sum + a[s]) / (ld)(j);
				ld nxt2 = (ld)(sum + a[e]) / (ld)(j);
				
				if(minn <= nxt1 && nxt1 <= maxx)
					sum += a[s--];
				else if(minn <= nxt2 && nxt2 <= maxx)
					sum += a[e++];
				
				else
				{
					if(abs(minn - nxt1) < abs(maxx - nxt2))
						sum += a[s--];
					else
						sum += a[e++];
				}
			}
			
			maxx = max(maxx, (ld)sum / (ld)j);
			minn = min(minn, (ld)sum / (ld)j);
		}
		
		ans = min(ans, maxx - minn);
	}
	
	cout << ans;
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -