Submission #921204

# Submission time Handle Problem Language Result Execution time Memory
921204 2024-02-03T13:43:18 Z PM1 Seesaw (JOI22_seesaw) C++17
100 / 100
142 ms 16316 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long double
#define fr first
#define sc second
const int mxn=2e5+5;
int n,a[mxn];
ll ps[mxn],mx,ans=1e9;
vector<pair<ll,ll>>v;
int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		ps[i]=ps[i-1]+a[i];
	}
	for(int i=1;i<n;i++){
		int L=1,R=n-i+1;
		while(R-L>1){
			int mid=(L+R)/2;
			ll x=(ps[mid+i-1]-ps[mid-1])/(ll)i;
			if(x<=(ps[n]/(ll)n))
				L=mid;
			else
				R=mid;
		}
		ll x=(ps[L+i-1]-ps[L-1])/i,y=(ps[L+i]-ps[L])/(ll)i;
		v.push_back({x,y});
		//cout<<x<<" "<<y<<endl;
	}
	v.push_back({ps[n]/(ll)n,ps[n]/(ll)n});
	sort(v.begin(),v.end());
	mx=v.back().fr;
	for(auto i:v){
		ll L=i.fr,R=mx;
		ans=min(ans,R-L);
		//cout<<L<<" "<<R<<endl;
		mx=max(mx,i.sc);
	}
	cout<<setprecision(10);
	cout<<ans<<'\n';
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 500 KB Output is correct
7 Correct 1 ms 600 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 500 KB Output is correct
7 Correct 1 ms 600 KB Output is correct
8 Correct 2 ms 604 KB Output is correct
9 Correct 2 ms 604 KB Output is correct
10 Correct 2 ms 604 KB Output is correct
11 Correct 2 ms 456 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 500 KB Output is correct
7 Correct 1 ms 600 KB Output is correct
8 Correct 2 ms 604 KB Output is correct
9 Correct 2 ms 604 KB Output is correct
10 Correct 2 ms 604 KB Output is correct
11 Correct 2 ms 456 KB Output is correct
12 Correct 142 ms 14588 KB Output is correct
13 Correct 140 ms 15552 KB Output is correct
14 Correct 139 ms 15544 KB Output is correct
15 Correct 140 ms 16316 KB Output is correct
16 Correct 142 ms 15548 KB Output is correct