QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#356057 | #8242. V-Diagram | ucup-team2681# | WA | 49ms | 3844kb | C++20 | 1.2kb | 2024-03-17 15:12:49 | 2024-03-17 15:12:49 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const int mod=998244353;
const int maxn=3e5+5;
inline int read() {
int x=0,f=1;
char ch=getchar();
while(ch<'0'||ch>'9') {if(ch=='-') f=-1;ch=getchar();}
while(ch>='0'&&ch<='9') {x=(x<<1)+(x<<3)+(ch^48);ch=getchar();}
return x*f;
}
typedef long long ll;
typedef long double lb;
ll now1,sum1,now2,sum2;
int T,n,a[maxn];
int main() {
T=read();
while(T--) {
n=read();
for(int i=1;i<=n;++i) a[i]=read();
int now=1,flag=0,p=0;
now1=sum1=now2=sum2=0;
if(a[1]<a[2]) flag=1;
lb ans=0.0;
while(now<=n) {
if(flag==0) {
while(a[now]>a[now+1]&&now+1<=n) now1++,sum1+=a[now],now++;
p=now,now++;
}
while(a[now]<a[now+1]&&now+1<=n) now2++,sum2+=a[now],now++;
if(now+1==n||a[now]>a[now+1]) now2++,sum2+=a[now],now++;
if(now1&&now2) {
sum1-=a[p-1],now1--;
sum2-=a[p+1],now2--;
ll res=a[p]+a[p-1]+a[p+1];
ans=max(ans,(lb)(sum1+sum2+res)/(lb)(now1+now2+3));
ans=max(ans,(lb)(sum1+res)/(lb)(now1+3));
ans=max(ans,(lb)(sum2+res)/(lb)(now2+3));
//printf("%lld %lld %lld %lld %lld 3\n",sum1,res,sum2,now1,now2);
}
while(now<=n&&a[now]==a[now+1]) now++;
}
printf("%.15Lf\n",ans);
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3844kb
input:
2 4 8 2 7 10 6 9 6 5 3 4 8
output:
6.750000000000000 5.833333333333333
result:
ok 2 numbers
Test #2:
score: -100
Wrong Answer
time: 49ms
memory: 3832kb
input:
100000 3 948511478 739365502 813471668 3 881046825 27458122 398507422 3 987554257 399092415 924260278 3 984128569 125199021 716360525 3 529589236 45783262 313507287 3 645443456 85994112 226010681 3 914820717 228360911 572267310 3 418958362 56703604 195276041 3 64461646 26764720 26995581 3 914535039 ...
output:
0.000000000000000 435670789.666666666656965 0.000000000000000 608562705.000000000000000 296293261.666666666656965 319149416.333333333343035 571816312.666666666686069 223646002.333333333328483 39407315.666666666667879 383253737.666666666656965 0.000000000000000 0.000000000000000 490276408.33333333334...
result:
wrong answer 1st numbers differ - expected: '833782882.6666666', found: '0.0000000', error = '1.0000000'