QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#425943 | #8685. Doing the Container Shuffle | kkkgjyismine4 | WA | 1ms | 8028kb | C++14 | 569b | 2024-05-30 19:25:09 | 2024-05-30 19:25:10 |
Judging History
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'