QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#727348 | #8242. V-Diagram | veg# | WA | 1ms | 7984kb | C++14 | 682b | 2024-11-09 12:53:05 | 2024-11-09 12:53:06 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int maxn=3e5+10;
int pre[maxn];
int nxt[maxn];
int a[maxn];
ll sum[maxn];
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
int n;
scanf("%d",&n);
for(int i=1;i<=n;i++) scanf("%d",&a[i]),sum[i]=sum[i-1]+a[i];
pre[1]=nxt[n]=0;
for(int i=2;i<=n;i++)
if(a[i]<a[i-1]) pre[i]=pre[i-1]+1;
else pre[i]=0;
for(int i=n-1;i;i--)
if(a[i]<a[i+1]) nxt[i]=nxt[i+1]+1;
else nxt[i]=0;
double ans=0;
for(int i=1;i<=n;i++)
if(pre[i]&&nxt[i])
ans=max(ans,1.0*(sum[i+nxt[i]]-sum[i-pre[i]-1])/(pre[i]+nxt[i]+1));
printf("%.6f\n",ans);
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 7984kb
input:
2 4 8 2 7 10 6 9 6 5 3 4 8
output:
6.750000 5.833333
result:
wrong answer 2nd numbers differ - expected: '5.8333333', found: '5.8333330', error = '0.0000001'