QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#444642 | #8524. Weather Forecast | ucup-team3924# | WA | 1ms | 4056kb | C++14 | 963b | 2024-06-15 20:35:30 | 2024-06-15 20:35:31 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
int check(long double avg, vector<long double>a){
for(auto &x : a)x -= avg;
stack<long double>S;
int n = a.size();
long double s = 0;
bool cb = false;
for(int i = 0; i < n; i++){
if(cb && a[i] >= 0){
S.push(s);
s = 0;
cb = false;
}
s += a[i];
if(s >= 0)cb = true;
}
if(cb)S.push(s);
while(s < 0 && !S.empty()){
s += S.top();
if(s >= 0)break;
S.pop();
}
return S.size();
}
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
int n, k;
cin >> n >> k;
vector<long double>a(n);
for(auto &x : a)cin >> x;
long double l = 1, r = 1000;
for(int i = 0; i < 200; i++){
long double mid = (l + r)/2;
if(check(mid, a) >= k - 1)l = mid;
else r = mid;
}
cout << fixed << setprecision(12) << l << '\n';
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3992kb
input:
7 3 1 3 1 2 2 2 1
output:
1.666666666667
result:
ok found '1.66667', expected '1.66667', error '0.00000'
Test #2:
score: -100
Wrong Answer
time: 1ms
memory: 4056kb
input:
1 1 1
output:
1000.000000000000
result:
wrong answer 1st numbers differ - expected: '1.00000', found: '1000.00000', error = '999.00000'