0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-11-27 15:56:26 +00:00

#149. 01 分数规划

https://loj.ac/s/1630402
This commit is contained in:
Baoshuo Ren 2022-11-12 11:58:11 +08:00
parent 2e2e032594
commit 957a1e8f42
Signed by: baoshuo
GPG Key ID: 00CB9680AB29F51A
101 changed files with 360 additions and 0 deletions

60
LibreOJ/149/149.cpp Normal file
View File

@ -0,0 +1,60 @@
#include <iostream>
#include <algorithm>
#include <iomanip>
using std::cin;
using std::cout;
const char endl = '\n';
const int N = 1e5 + 5;
const double eps = 1e-7;
int n, k, a[N], b[N];
double c[N];
inline bool check(double mid) {
double sum = 0;
for (int i = 1; i <= n; i++) {
c[i] = static_cast<double>(a[i]) - mid * b[i];
}
std::sort(c + 1, c + 1 + n, std::greater<>());
for (int i = 1; i <= k; i++) {
sum += c[i];
}
return sum >= 0;
}
int main() {
std::ios::sync_with_stdio(false);
cin.tie(nullptr);
cin >> n >> k;
for (int i = 1; i <= n; i++) {
cin >> a[i];
}
for (int i = 1; i <= n; i++) {
cin >> b[i];
}
double l = 0, r = 1e9;
while (r - l > eps) {
double mid = (l + r) / 2;
if (check(mid)) {
l = mid;
} else {
r = mid;
}
}
cout << std::fixed << std::setprecision(4) << l << endl;
return 0;
}

BIN
LibreOJ/149/data/1.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/149/data/1.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/149/data/10.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/149/data/10.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/149/data/11.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/149/data/11.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/149/data/12.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/149/data/12.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/149/data/13.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/149/data/13.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/149/data/14.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/149/data/14.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/149/data/15.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/149/data/15.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/149/data/16.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/149/data/16.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/149/data/17.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/149/data/17.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/149/data/18.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/149/data/18.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/149/data/19.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/149/data/19.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/149/data/2.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/149/data/2.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/149/data/20.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/149/data/20.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/149/data/21.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/149/data/21.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/149/data/22.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/149/data/22.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/149/data/23.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/149/data/23.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/149/data/24.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/149/data/24.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/149/data/25.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/149/data/25.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/149/data/26.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/149/data/26.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/149/data/27.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/149/data/27.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/149/data/28.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/149/data/28.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/149/data/29.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/149/data/29.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/149/data/3.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/149/data/3.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/149/data/30.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/149/data/30.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/149/data/31.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/149/data/31.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/149/data/32.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/149/data/32.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/149/data/33.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/149/data/33.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/149/data/34.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/149/data/34.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/149/data/35.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/149/data/35.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/149/data/36.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/149/data/36.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/149/data/37.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/149/data/37.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/149/data/38.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/149/data/38.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/149/data/39.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/149/data/39.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/149/data/4.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/149/data/4.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/149/data/40.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/149/data/40.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/149/data/41.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/149/data/41.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/149/data/42.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/149/data/42.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/149/data/43.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/149/data/43.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/149/data/44.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/149/data/44.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/149/data/45.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/149/data/45.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/149/data/46.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/149/data/46.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/149/data/47.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/149/data/47.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/149/data/48.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/149/data/48.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/149/data/49.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/149/data/49.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/149/data/5.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/149/data/5.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/149/data/50.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/149/data/50.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/149/data/6.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/149/data/6.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/149/data/7.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/149/data/7.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/149/data/8.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/149/data/8.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/149/data/9.in (Stored with Git LFS) Normal file

Binary file not shown.

Some files were not shown because too many files have changed in this diff Show More