QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#425943#8685. Doing the Container Shufflekkkgjyismine4WA 1ms8028kbC++14569b2024-05-30 19:25:092024-05-30 19:25:10

Judging History

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

  • [2024-05-30 19:25:10]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:8028kb
  • [2024-05-30 19:25:09]
  • 提交

answer

#include<bits/stdc++.h>
#define db double
using namespace std;
int n,pos[1000005],a[1000005];
struct BIT{
	int ct[1000005];
	void add(int p,int o){for(int i=p;i<=n;i+=(i&-i))ct[i]+=o;}
	int qry(int p){
		int res=0;
		for(int i=p;i;i&=(i-1))res+=ct[i];
		return res;
	}
}fwk;
int main(){
	scanf("%d",&n);
	db ans=(db)n;
	for(int i=1;i<=n;++i)scanf("%d",&a[i]),pos[a[i]]=i,fwk.add(i,1);
	int mn=n+1;
	for(int i=1;i<=n;++i){
		fwk.add(pos[i],-1),mn=min(mn,pos[i]);
		ans+=(db)(fwk.qry(n)-fwk.qry(mn-1))*0.5000;
	}printf("%.10lf\n",ans);
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

1
1

output:

1.0000000000

result:

ok found '1.00000', expected '1.00000', error '0.00000'

Test #2:

score: -100
Wrong Answer
time: 0ms
memory: 8028kb

input:

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

output:

34.5000000000

result:

wrong answer 1st numbers differ - expected: '31.50000', found: '34.50000', error = '0.09524'