QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#769297#8050. Random PermutationDaiRuiChen007WA 1ms5816kbC++17596b2024-11-21 17:00:452024-11-21 17:00:46

Judging History

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

  • [2024-11-21 17:00:46]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:5816kb
  • [2024-11-21 17:00:45]
  • 提交

answer

#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int MAXN=3e5+5;
int a[MAXN],w[MAXN<<1];
int f(double e) { return max(15./e/e,100.); }
signed main() {
	int n; ll ans=0;
	scanf("%d",&n);
	for(int i=1;i<=n;++i) scanf("%d",&a[i]);
	for(int i=1;i<=n;++i) {
		int rd=2*i==n?n:f(abs(0.5-1.*i/n));
		int l=max(1,i-rd+1),r=min(n,i+rd-1),len=r-l+1;
		for(int j=i,s=n;j>=l;--j) s+=a[j]>a[i]?1:-1,++w[s];
		for(int j=i,s=n+1;j<=r;++j) s+=a[j]>a[i]?1:-1,ans+=1ll*i*(w[2*n-s]+w[2*n-1-s]);
		for(int x=n-len;x<=n+len;++x) w[x]=0;
	}
	printf("%lld\n",ans);
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

4
1 4 2 3

output:

27

result:

wrong answer 1st numbers differ - expected: '22', found: '27'