# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1063622 |
2024-08-17T21:25:09 Z |
TimDee |
Seesaw (JOI22_seesaw) |
C++17 |
|
1 ms |
604 KB |
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define forn(i,n) for(int i=0; i<n; ++i)
#define vii(a,n) vector<int> a(n); forn(i,n) cin>>a[i];
#define f first
#define s second
#define pb push_back
#define all(x) x.begin(),x.end()
const double one = 1;
const int N=1005;
int a[N];
void solve() {
int n; cin>>n;
forn(i,n) cin>>a[i];
vector<pair<double,int>> v;
forn(i,n) {
int s=0;
for(int j=i; j<n; ++j) {
s+=a[j];
double z = 1.0*s/(j-i+1);
v.pb({z,j-i});
}
}
sort(all(v));
vector<int> cnt(n);
int tot=0;
int r=0;
double ans=a[n-1]-a[0];
int m=v.size();
forn(i,m) {
while (r<m && tot<n) {
tot+=!cnt[v[r].s];
++cnt[v[r].s];
++r;
}
if (tot==n) ans=min(ans,v[r-1].f - v[i].f);
--cnt[v[i].s];
tot-=!cnt[v[i].s];
}
cout<<fixed<<setprecision(10)<<ans<<'\n';
}
int32_t main() {
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
solve();
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 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 |
0 ms |
344 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 |
604 KB |
Output is correct |
5 |
Correct |
1 ms |
604 KB |
Output is correct |
6 |
Correct |
1 ms |
604 KB |
Output is correct |
7 |
Correct |
1 ms |
604 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 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 |
604 KB |
Output is correct |
5 |
Correct |
1 ms |
604 KB |
Output is correct |
6 |
Correct |
1 ms |
604 KB |
Output is correct |
7 |
Correct |
1 ms |
604 KB |
Output is correct |
8 |
Runtime error |
1 ms |
604 KB |
Execution killed with signal 11 |
9 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 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 |
604 KB |
Output is correct |
5 |
Correct |
1 ms |
604 KB |
Output is correct |
6 |
Correct |
1 ms |
604 KB |
Output is correct |
7 |
Correct |
1 ms |
604 KB |
Output is correct |
8 |
Runtime error |
1 ms |
604 KB |
Execution killed with signal 11 |
9 |
Halted |
0 ms |
0 KB |
- |