# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
677688 | mjhmjh1104 | Seesaw (JOI22_seesaw) | C++17 | 72 ms | 264 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <cstdio>
#include <numeric>
#include <algorithm>
using namespace std;
int n, a[200006];
int main() {
scanf("%d", &n);
for (int i = 0; i < n; i++) scanf("%d", a + i);
double res = 1 / 0.;
for (int i = 0; i < 1 << n; i++) {
int l = 0, r = n - 1;
long long sum = accumulate(a, a + n, 0LL);
int cnt = n;
double curr = sum / (double)cnt;
double mx = curr, mn = curr;
for (int j = 0; j < n; j++) {
if (i & 1 << j) sum -= a[l++];
else sum -= a[r--];
cnt--;
curr = sum / (double)cnt;
mx = max(mx, curr);
mn = min(mn, curr);
}
res = min(res, mx - mn);
}
printf("%.10f", res);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |