QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#637635#8242. V-DiagramwzxtslWA 152ms3948kbC++231.2kb2024-10-13 13:37:082024-10-13 13:37:08

Judging History

你现在查看的是最新测评结果

  • [2024-10-13 13:37:08]
  • 评测
  • 测评结果:WA
  • 用时:152ms
  • 内存:3948kb
  • [2024-10-13 13:37:08]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define fast ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define For(i,j,k) for (int i=(j);i<=(k);i++)
#define rof(i,j,k) for (int i=(j);i>=(k);i--)
#define ull unsigned long long
#define lowbit(x) ((x)&(-(x)))
#define PII pair<int,int>
#define int long long
#define endl "\n"
#define ls rt<<1
#define rs rt<<1|1
typedef long long ll;
const int mod = 998244353;
const double eps = 1e-9;
const int N=2e6+7;
int n,m;
int a[N];
void solve(){
	cin>>n;
    double ans=0;
    int cnt=0;
    int cn=0;
    double mi=0x3f3f3f3f;
    double sum=0;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        if(a[i]<mi) mi=a[i],cnt=i;
    }
    sum=a[cnt];
    ans=a[cnt];
    double tem=sum;
    double an=ans;
    for(int i=cnt+1;i<=n;i++){
        tem+=a[i];
        an=tem/(i-cnt+1);
        if(an>ans){
            ans=an;
            sum=tem;
            cn=i;
        }
    }
    for(int i=cnt-1;i>=1;i--){
        tem+=a[i];
        an=tem/(cn-i+1);
        if(an>ans){
            ans=an;
            sum=tem;
        }
    }
    cout<<fixed<<setprecision(15)<<endl;
    cout<<ans<<endl;
}
signed main(){
	int t=1;
	cin>>t;
	while(t--){
		solve();
	}
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3948kb

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: 0
Accepted
time: 152ms
memory: 3888kb

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:


833782882.666666626930237

435670789.666666686534882

770302316.666666626930237

608562705.000000000000000

296293261.666666686534882

319149416.333333313465118

571816312.666666626930237

223646002.333333343267441

39407315.666666664183140

383253737.666666686534882

734363638.666666626930237

779...

result:

ok 100000 numbers

Test #3:

score: -100
Wrong Answer
time: 94ms
memory: 3948kb

input:

10000
4
194123849 79274911 191162487 570110764
86
957917218 915359202 914726017 873273226 867724859 867674150 809652204 805531383 745262007 743835491 727071232 714782071 645394643 639432679 594879540 587173904 583418126 560538589 518721836 469558994 427721766 411582333 404948350 402948978 357228675 ...

output:


280182720.666666686534882

538557639.954545497894287

495489050.352941155433655

537734928.641025662422180

472025965.699999988079071

543693608.250000000000000

543366581.516129016876221

254833443.199999988079071

447343683.315789461135864

502458665.384615361690521

564217787.333333373069763

47...

result:

wrong answer 1st numbers differ - expected: '258668002.7500000', found: '280182720.6666667', error = '0.0831750'