QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#442394 | #8524. Weather Forecast | ucup-team3282# | WA | 1ms | 3956kb | C++14 | 870b | 2024-06-15 11:36:47 | 2024-06-15 11:36:48 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5+9;
int n, k;
double a[N];
bool check(double mid) {
int nw=1,cnt=0;
while(cnt<k-1){
double sum=0,num=0;
bool flag=false;
for(;nw<=n;nw++){
sum+=a[nw];num++;
if(sum>=mid*num){
flag=true;
break;
}
}
if(!flag)return false;
for(nw++;nw<=n;nw++){
if(a[nw]>=mid||sum+a[nw]<mid*(num+1))break;
sum+=a[nw];num++;
}
cnt++;
}
if(nw>n)return false;
double sum=0,num=0;
for(;nw<=n;nw++){
sum+=a[nw];num++;
}
return sum>=num*mid;
}
int main() {
// freopen("2.in", "r", stdin);
cin >> n >> k;
for (int i = 1; i <= n; i++) cin >> a[i];
double l = 0.0, r = 1e9, ans = 0.0;
while (l + 1E-9< r) {
double mid = (l + r) / 2.0;
if (check(mid)) {
ans = mid;
l = mid;
} else r = mid;
}
cout << ans;
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3904kb
input:
7 3 1 3 1 2 2 2 1
output:
1.66667
result:
ok found '1.66667', expected '1.66667', error '0.00000'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3852kb
input:
1 1 1
output:
1
result:
ok found '1.00000', expected '1.00000', error '0.00000'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3908kb
input:
2 1 2 1
output:
1.5
result:
ok found '1.50000', expected '1.50000', error '0.00000'
Test #4:
score: 0
Accepted
time: 0ms
memory: 3956kb
input:
3 2 2 4 4
output:
3
result:
ok found '3.00000', expected '3.00000', error '0.00000'
Test #5:
score: 0
Accepted
time: 0ms
memory: 3692kb
input:
4 2 6 7 3 12
output:
6.5
result:
ok found '6.50000', expected '6.50000', error '0.00000'
Test #6:
score: 0
Accepted
time: 0ms
memory: 3956kb
input:
5 3 17 23 13 12 21
output:
16.5
result:
ok found '16.50000', expected '16.50000', error '0.00000'
Test #7:
score: 0
Accepted
time: 1ms
memory: 3696kb
input:
7 4 3 37 46 23 46 6 31
output:
23
result:
ok found '23.00000', expected '23.00000', error '0.00000'
Test #8:
score: 0
Accepted
time: 1ms
memory: 3820kb
input:
10 5 30 91 36 53 74 91 37 1 76 3
output:
39.5
result:
ok found '39.50000', expected '39.50000', error '0.00000'
Test #9:
score: -100
Wrong Answer
time: 0ms
memory: 3816kb
input:
100 50 593 336 577 842 505 78 665 825 990 895 952 782 721 242 421 951 786 994 238 154 356 483 686 143 220 473 920 353 738 690 96 915 913 157 412 882 465 585 963 635 68 72 901 143 50 558 310 504 987 97 588 987 841 829 780 497 758 909 503 585 91 657 912 870 663 606 748 492 175 92 375 768 773 206 676 8...
output:
462
result:
wrong answer 1st numbers differ - expected: '483.00000', found: '462.00000', error = '21.00000'