QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#440324#8049. Equal Sumsship2077WA 1ms6180kbC++14950b2024-06-13 16:22:182024-06-13 16:22:18

Judging History

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

  • [2024-06-13 16:22:18]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:6180kb
  • [2024-06-13 16:22:18]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
constexpr int M=3e5+5;long long ans,cnt;
int n,block,len,p[M],a[M],buc[M<<1];
int read(){
    int x=0;char ch=getchar();
    while (!isdigit(ch)) ch=getchar();
    while (isdigit(ch)) x=x*10+ch-48,ch=getchar();
    return x;
}
double fun(double p,double eps){
    return min(1e9,fabs(p-0.5)<1e-9?1e9:log(eps)/(log(2)+log(p)/2+log(1-p)/2));
}
int main(){ n=read();
    for (int i=1;i<=n;i++) p[i]=read();
    for (int i=1;i<=n;i++){
        len=fun(1.*p[i]/n,3e-6);
        int l=max(1,i-len),r=min(n,i+len); a[l-1]=r-l+1;
        for (int k=l;k<=r;k++) a[k]=a[k-1]+(p[k]>p[i]?1:-1);
        for (int k=l;k<=i;k++) buc[a[k-1]]++; long long sum=0;
        for (int k=i;k<=r;k++) sum+=buc[a[k]]+buc[a[k]+1];
        ans+=1ll*p[i]*sum;cnt+=sum;
        for (int k=l;k<=i;k++) buc[a[k-1]]=0;
    }
    // cerr<<cnt<<":"<<1ll*n*(n+1)/2<<endl;
    printf("%lld\n",ans);
    return 0;
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 6180kb

input:

2 3
1 2
2 3
1 4
2 2
1 3

output:

5

result:

wrong answer 1st numbers differ - expected: '2', found: '5'