# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
526875 | eecs | Let's Win the Election (JOI22_ho_t3) | C++17 | 914 ms | 2376 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
const int maxn = 510;
int n, K, b;
double f[maxn][maxn];
array<int, 2> a[maxn];
void chk(double &x, double y) {
if (x > y) x = y;
}
int main() {
scanf("%d %d", &n, &K);
for (int i = 1; i <= n; i++) {
scanf("%d %d", &a[i][1], &a[i][0]);
if (~a[i][0]) b++;
}
sort(a + 1, a + n + 1);
auto calc = [&](int num) {
for (int i = 0; i <= n; i++) {
fill(f[i], f[i] + n + 1, 1e18);
}
f[0][0] = 0;
for (int i = 0; i < n; i++) {
for (int j = min(i, num); ~j; j--) {
for (int k = i - j; ~k; k--) {
if (~a[i + 1][0]) chk(f[j + 1][k], f[j][k] + 1.0 * a[i + 1][0] / (j + 1));
chk(f[j][k + 1], f[j][k] + 1.0 * a[i + 1][1] / (num + 1));
}
}
}
return f[num][K - num];
};
int l = 0, r = min(b, K);
while (l < r) {
int mid = (l + r) / 2;
calc(mid) > calc(mid + 1) ? l = mid + 1 : r = mid;
}
printf("%.9f\n", calc(l));
return 0;
}
컴파일 시 표준 에러 (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... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |