Save the Queen!

  • + 0 comments

    the editorial is so hard.Look at it once.

    def solve(n, a):
        a=sorted(a,reverse=True);
        reallis=a[:n];
        sum1=sum(a[n:]);
        #print(reallis,sum1)
        reallis=sorted(reallis);
        temp=0;
        sum2=0;
        no=0;
        f=0;
        for i in range(len(reallis)):
            no+=1;
            sum2+=reallis[i];
            temp=round((sum1+sum2),9)/no;
            #print(temp);
            if(i<(len(reallis)-1)):
                if(temp<=reallis[i+1]):
                    f=1;
                    print("{0:.9f}".format(temp));
    
                break;
            else:
                continue;
    if(f==0):
        print("{0:.9f}".format(temp));