QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#742924 | #8524. Weather Forecast | ucup-team2526 | WA | 0ms | 3888kb | C++20 | 1.1kb | 2024-11-13 17:39:23 | 2024-11-13 17:39:24 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define dbg(x...) \
do { \
std::cout << #x << " -> "; \
err(x); \
} while (0)
void err() {
std::cout << std::endl;
}
template<class T, class... Ts>
void err(T arg, Ts &... args) {
std::cout << fixed << setprecision(10) << arg << ' ';
err(args...);
}
void GENSHEN_START() {
int n,k;cin >> n >> k;
vector <int> a(n + 5);
for (int i = 1;i <= n;i++) cin >> a[i];
auto check = [&](double x) -> bool {
int cnt = 0,ok = 0;
for (int i = 1;i <= n;i++) {
int j = i,sum = 0;
for (;j <= n;j++) {
sum += a[j];
double ave = sum * 1.0 / (j - i + 1);
if (ave >= x) {
cnt++;
break;
}
}
i = j;
}
//dbg(x,cnt);
if (cnt >= k) return 1;
else return 0;
};
double l = 0,r = 1000,ans = 0;
while (r - l >= 1e-10) {
double mid = (l + r) * 1.0 / 2;
if (check(mid)) {
l = mid;
ans = max(ans,mid);
}
else r = mid;
//dbg(l,r);
}
cout << setprecision(12) << ans;
}
signed main()
{
ios::sync_with_stdio(false);cin.tie(nullptr);
int T = 1;
//cin >> T;
while (T--) GENSHEN_START();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3804kb
input:
7 3 1 3 1 2 2 2 1
output:
1.66666666667
result:
ok found '1.66667', expected '1.66667', error '0.00000'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3756kb
input:
1 1 1
output:
0.999999999976
result:
ok found '1.00000', expected '1.00000', error '0.00000'
Test #3:
score: -100
Wrong Answer
time: 0ms
memory: 3888kb
input:
2 1 2 1
output:
1.99999999995
result:
wrong answer 1st numbers differ - expected: '1.50000', found: '2.00000', error = '0.50000'