QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#706813#8242. V-Diagramgreenqwq#WA 61ms6060kbC++171.8kb2024-11-03 13:32:552024-11-03 13:32:56

Judging History

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

  • [2024-11-03 13:32:56]
  • 评测
  • 测评结果:WA
  • 用时:61ms
  • 内存:6060kb
  • [2024-11-03 13:32:55]
  • 提交

answer

//#pragma GCC optimize(1)
//#pragma GCC optimize(2)
//#pragma GCC optimize(3,"Ofast","inline")

#include<bits/stdc++.h>

using namespace std;

#define x first
#define y second
#define int long long
#define ll __int128
#define double long double
#define lowbit(x) (x&(-x))
#define log(x) (31^__builtin_clz(x))
#define endl '\n'

typedef pair<int,int>PII;
typedef pair<double,double>PDD;
typedef tuple<double,double,double>TDDD;
typedef tuple<int,int,int>TIII;

const int N = 2e5+10;
const int mod = 1e9+7 , P = 131;
const double PI = acos(-1);
const double eps = 1e-8;

mt19937_64 rng((unsigned int) chrono::steady_clock::now().time_since_epoch().count());//随机数


int read(){
    char c=0;
    int res=0;
    int f=1;
    while(!(c>='0'&&c<='9')){
        if(c=='-'){
            f=-f;
        }
        c=getchar();
    }
    while(c>='0'&&c<='9'){
        res=(res<<3)+(res<<1)+c-'0';
        c=getchar();
    }
    return res*f;
}

void write(int x){
    if(x<0){putchar('-');x=-x;}
    if(x>9) write(x/10);
    putchar(char(x%10+'0'));
}

int n,w[N];
int pre[N];

void solve(){
    cin>>n;

    int minv=1e18,id=0;

    for(int i=1;i<=n;i++){
        cin>>w[i];
        pre[i]=pre[i-1]+w[i];
        if(w[i]<minv){
            minv=w[i];
            id=i;
        }
    }

    double ans=0;

    int l=id,r=id;
    while(l>=1||r<=n){
        l--,r++;
        if(l<1&&r<=n)l=1;
        if(r>n&&l>=1)r=n;
        ans=max(ans,(double)(pre[r]-pre[l-1])/(r-l+1));
    }

    printf("%.12Lf\n",ans);

}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0),cout.tie(0);
    int T;
    cin>>T;
    while(T--)solve();

#ifdef GREENQWQ
    cerr<<fixed<<setprecision(10)<<1.0*clock()/CLOCKS_PER_SEC<<endl;
#endif
    return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 5944kb

input:

2
4
8 2 7 10
6
9 6 5 3 4 8

output:

6.750000000000
5.833333333333

result:

ok 2 numbers

Test #2:

score: 0
Accepted
time: 61ms
memory: 3928kb

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.666666666686
435670789.666666666657
770302316.666666666686
608562705.000000000000
296293261.666666666657
319149416.333333333343
571816312.666666666686
223646002.333333333328
39407315.666666666668
383253737.666666666657
734363638.666666666686
779975824.333333333314
490276408.333333333343
57...

result:

ok 100000 numbers

Test #3:

score: -100
Wrong Answer
time: 24ms
memory: 6060kb

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:

258668002.750000000000
499947495.383720930229
713349817.947368421068
511519421.863013698632
736078846.583333333314
720390820.928571428580
543366581.516129032243
790711720.285714285739
470222949.048780487792
502458665.384615384624
693762499.125000000000
479468115.118279569899
525254125.152173913055
5...

result:

wrong answer 2nd numbers differ - expected: '527118856.7555556', found: '499947495.3837209', error = '0.0515469'