# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1070641 |
2024-08-22T16:21:32 Z |
prvocislo |
Seesaw (JOI22_seesaw) |
C++17 |
|
2000 ms |
5456 KB |
// I was grinning like I'm winning, I was hitting my marks
// 'Cause I can do it with a broken heart
// 1 2 3 4 ...
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <bitset>
typedef long long ll;
typedef long double ld;
using namespace std;
vector<ll> a, pf;
ld avg(int l, int r) { return (ld)(pf[r + 1] - pf[l]) / (ld)(r - l + 1); }
void chmax(ld& a, ld b) { a = max(a, b); }
void chmin(ld& a, ld b) { a = min(a, b); }
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
int n;
cin >> n;
a.assign(n, 0), pf.assign(n + 1, 0);
for (int i = 0; i < n; i++) cin >> a[i], pf[i + 1] = pf[i] + a[i];
ld ans = a[n - 1];
for (int l = 0; l < n; l++) for (int r = l; r < n; r++)
{
ld c = avg(l, r);
ld mi = avg(0, n-1);
ld mx = avg(0, n-1);
if (c > mi || mi - c > ans) continue;
int li = 0, ri = n - 1;
while (li < ri)
{
if (avg(li, ri - 1) >= c) ri--;
else li++;
chmin(mi, avg(li, ri));
chmax(mx, avg(li, ri));
}
chmin(ans, mx - mi);
}
cout << setprecision(9) << fixed;
cout << ans << "\n";
return 0;
}
# |
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 |
0 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 |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
5 |
Correct |
0 ms |
456 KB |
Output is correct |
6 |
Correct |
0 ms |
456 KB |
Output is correct |
7 |
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 |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
5 |
Correct |
0 ms |
456 KB |
Output is correct |
6 |
Correct |
0 ms |
456 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
61 ms |
348 KB |
Output is correct |
9 |
Correct |
59 ms |
348 KB |
Output is correct |
10 |
Correct |
53 ms |
344 KB |
Output is correct |
11 |
Correct |
59 ms |
480 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 |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
5 |
Correct |
0 ms |
456 KB |
Output is correct |
6 |
Correct |
0 ms |
456 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
61 ms |
348 KB |
Output is correct |
9 |
Correct |
59 ms |
348 KB |
Output is correct |
10 |
Correct |
53 ms |
344 KB |
Output is correct |
11 |
Correct |
59 ms |
480 KB |
Output is correct |
12 |
Execution timed out |
2029 ms |
5456 KB |
Time limit exceeded |
13 |
Halted |
0 ms |
0 KB |
- |