QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#649206 | #8242. V-Diagram | Aa# | WA | 0ms | 6012kb | C++17 | 796b | 2024-10-17 22:04:57 | 2024-10-17 22:04:57 |
Judging History
answer
#include <iostream>
#include <algorithm>
using namespace std;
const double INF=1e18;
int n;
int a[300010];
double s[300010];
bool check(double mid){
for(int i=1;i<=n;i++)
s[i]=s[i-1]+(double)a[i]-mid;
double mi=INF;
for(int i=1;i<n;i++){
if(a[i]>a[i+1]) mi=min(mi,s[i-1]);
else if(a[i]==a[i+1]) mi=INF;
else if(mi!=INF){
int j=i+1;
while(j<=n && a[j]>a[j-1]){
if(s[j++]-mi>=0) return true;
}
mi=INF;
i=j-2;
}
}
return false;
}
signed main(){
int t;
scanf("%d",&t);
while(t--){
double l=0,r=0;
scanf("%d",&n);
for(int i=1;i<=n;i++){
scanf("%d",&a[i]);
r=max(r,(double)a[i]);
}
while(r-l>1e-6){
double mid=(l+r)/2;
if(check(mid)) l=mid;
else r=mid;
}
printf("%.18lf\n",r);
}
return 0;
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 6012kb
input:
2 4 8 2 7 10 6 9 6 5 3 4 8
output:
6.750000119209289551 5.833333611488342285
result:
wrong answer 1st numbers differ - expected: '6.7500000', found: '6.7500001', error = '0.0000000'