QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#442476 | #8524. Weather Forecast | ucup-team2010# | WA | 0ms | 4056kb | C++20 | 985b | 2024-06-15 12:19:15 | 2024-06-15 12:19:16 |
Judging History
answer
#include <bits/stdc++.h>
using i64 = long long;
bool check(const std::vector<int>& a, int n, int k, double mid) {
std::vector<double> adj(n);
for (int i = 0; i < n; ++i) {
adj[i] = a[i] - mid;
}
double sum = 0;
int cnt = 0;
for (int i = 0; i < n; ++i) {
sum += adj[i];
if (sum >= 0) {
cnt++;
sum = 0;
}
}
return cnt >= k;
}
int main() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
int n, k;
std::cin >> n >> k;
std::vector<int> a(n);
for (int i = 0; i < n; ++i) {
std::cin >> a[i];
}
double lo = 1.0, hi = 1000.0;
while (hi - lo > 1e-9) {
double mid = lo + (hi - lo) / 2;
if (check(a, n, k, mid)) {
lo = mid + 1e-9;
} else {
hi = mid - 1e-9;
}
}
std::cout << std::fixed << std::setprecision(9) << lo;
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3816kb
input:
7 3 1 3 1 2 2 2 1
output:
1.666666667
result:
ok found '1.66667', expected '1.66667', error '0.00000'
Test #2:
score: 0
Accepted
time: 0ms
memory: 4056kb
input:
1 1 1
output:
1.000000000
result:
ok found '1.00000', expected '1.00000', error '0.00000'
Test #3:
score: -100
Wrong Answer
time: 0ms
memory: 4044kb
input:
2 1 2 1
output:
2.000000000
result:
wrong answer 1st numbers differ - expected: '1.50000', found: '2.00000', error = '0.50000'