0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-12-24 03:31:59 +00:00

#1816. 【2017.3 长乐省选集训 Day18 T2】子集

https://sjzezoj.com/submission/66531
This commit is contained in:
Baoshuo Ren 2022-12-31 10:19:21 +08:00
parent 024dd9b809
commit 4cd9aa2cfa
Signed by: baoshuo
GPG Key ID: 00CB9680AB29F51A
46 changed files with 191 additions and 0 deletions

56
S2OJ/1816/1816.cpp Normal file
View File

@ -0,0 +1,56 @@
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <iterator>
#include <numeric>
using std::cin;
using std::cout;
const char endl = '\n';
const int N = 2e5 + 5;
int n, a[N], s[N];
double ans;
double calc(int pos, int len) {
return static_cast<double>(s[n] - s[n - len] + s[pos] - s[pos - len - 1]) / (len * 2 + 1);
}
int solve(int x) {
int l = 1,
r = std::min(x - 1, n - x),
res = 0;
while (l <= r) {
int mid = (l + r) >> 1;
if (calc(x, mid - 1) <= calc(x, mid)) {
res = mid;
l = mid + 1;
} else {
r = mid - 1;
}
}
return res;
}
int main() {
std::ios::sync_with_stdio(false);
cin.tie(nullptr);
cin >> n;
std::copy_n(std::istream_iterator<int>(cin), n, a + 1);
std::sort(a + 1, a + 1 + n);
std::partial_sum(a + 1, a + 1 + n, s + 1);
for (int i = 2; i < n; i++) {
ans = std::max(ans, calc(i, solve(i)) - a[i]);
}
cout << std::fixed << std::setprecision(5) << ans << endl;
return 0;
}

BIN
S2OJ/1816/data/ex_subset1.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1816/data/ex_subset1.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1816/data/ex_subset2.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1816/data/ex_subset2.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1816/data/problem.conf (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1816/data/subset1.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1816/data/subset1.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1816/data/subset10.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1816/data/subset10.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1816/data/subset11.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1816/data/subset11.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1816/data/subset12.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1816/data/subset12.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1816/data/subset13.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1816/data/subset13.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1816/data/subset14.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1816/data/subset14.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1816/data/subset15.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1816/data/subset15.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1816/data/subset16.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1816/data/subset16.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1816/data/subset17.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1816/data/subset17.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1816/data/subset18.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1816/data/subset18.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1816/data/subset19.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1816/data/subset19.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1816/data/subset2.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1816/data/subset2.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1816/data/subset20.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1816/data/subset20.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1816/data/subset3.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1816/data/subset3.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1816/data/subset4.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1816/data/subset4.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1816/data/subset5.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1816/data/subset5.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1816/data/subset6.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1816/data/subset6.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1816/data/subset7.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1816/data/subset7.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1816/data/subset8.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1816/data/subset8.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1816/data/subset9.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/1816/data/subset9.in (Stored with Git LFS) Normal file

Binary file not shown.