0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-11-23 17:48:48 +00:00

2428. [HAOI2006] 均分数据

https://hydro.ac/d/bzoj/record/633263575741ce0221187c0e
This commit is contained in:
Baoshuo Ren 2022-09-27 10:43:53 +08:00
parent af265431c4
commit 2265bb7b7a
Signed by: baoshuo
GPG Key ID: 00CB9680AB29F51A
21 changed files with 105 additions and 0 deletions

45
BZOJ/2428/2428.cpp Normal file
View File

@ -0,0 +1,45 @@
#include <iostream>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <numeric>
#include <random>
#include <vector>
using std::cin;
using std::cout;
const char endl = '\n';
int main() {
std::ios::sync_with_stdio(false);
cin.tie(nullptr);
int n, m;
double ans = 1e9;
std::mt19937 rng(std::random_device{}());
cin >> n >> m;
std::vector<int> a(n);
for (int& x : a) cin >> x;
for (int i = 0; i < 1000000; i++) {
std::vector<int> b(m);
std::shuffle(a.begin(), a.end(), rng);
for (int x : a) {
*std::min_element(b.begin(), b.end()) += x;
}
double avg = static_cast<double>(std::accumulate(b.begin(), b.end(), 0)) / m;
double variance = std::sqrt(std::accumulate(b.begin(), b.end(), 0.0, [&](double sum, int x) { return sum + std::pow(avg - x, 2); }) / m);
ans = std::min(ans, variance);
}
cout << std::fixed << std::setprecision(2) << ans << endl;
return 0;
}

BIN
BZOJ/2428/data/1.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/2428/data/1.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/2428/data/10.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/2428/data/10.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/2428/data/2.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/2428/data/2.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/2428/data/3.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/2428/data/3.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/2428/data/4.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/2428/data/4.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/2428/data/5.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/2428/data/5.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/2428/data/6.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/2428/data/6.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/2428/data/7.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/2428/data/7.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/2428/data/8.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/2428/data/8.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/2428/data/9.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/2428/data/9.out (Stored with Git LFS) Normal file

Binary file not shown.