QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#425960 | #8685. Doing the Container Shuffle | kkkgjyismine4 | WA | 96ms | 15688kb | C++14 | 602b | 2024-05-30 19:39:02 | 2024-05-30 19:39:03 |
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);
if(i==1)mn=pos[i];else mn=min(pos[i-1],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: 0ms
memory: 8036kb
input:
1 1
output:
1.0000000000
result:
ok found '1.00000', expected '1.00000', error '0.00000'
Test #2:
score: 0
Accepted
time: 1ms
memory: 8004kb
input:
11 5 9 1 3 11 10 2 4 6 8 7
output:
31.5000000000
result:
ok found '31.50000', expected '31.50000', error '0.00000'
Test #3:
score: 0
Accepted
time: 82ms
memory: 15688kb
input:
1000000 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 ...
output:
250000750000.0000000000
result:
ok found '250000750000.00000', expected '250000750000.00000', error '0.00000'
Test #4:
score: 0
Accepted
time: 96ms
memory: 15620kb
input:
1000000 1000000 999999 999998 999997 999996 999995 999994 999993 999992 999991 999990 999989 999988 999987 999986 999985 999984 999983 999982 999981 999980 999979 999978 999977 999976 999975 999974 999973 999972 999971 999970 999969 999968 999967 999966 999965 999964 999963 999962 999961 999960 9999...
output:
1000000.0000000000
result:
ok found '1000000.00000', expected '1000000.00000', error '0.00000'
Test #5:
score: -100
Wrong Answer
time: 92ms
memory: 15688kb
input:
1000000 1000000 1 999999 2 999998 3 999997 4 999996 5 999995 6 999994 7 999993 8 999992 9 999991 10 999990 11 999989 12 999988 13 999987 14 999986 15 999985 16 999984 17 999983 18 999982 19 999981 20 999980 21 999979 22 999978 23 999977 24 999976 25 999975 26 999974 27 999973 28 999972 29 999971 30 ...
output:
125000999999.5000000000
result:
wrong answer 1st numbers differ - expected: '250000250000.50000', found: '125000999999.50000', error = '0.50000'