Problem: We have held a popularity poll for N items on sale. Item i received A_i votes.  From these N items, we will select M as popular items. However, we cannot select an item with less than \dfrac{1}{4M} of the total number of votes.  If M popular items can be selected, print `Yes`; otherwise, print `No`.

Submission attempts (in order):
n,m=map(int,input().split())
a=list(map(int,input().split()))

new_a=sorted(a,reverse=True)
sums=sum(a)

if new_a[m-1]>=sums/(b*4):
    print("Yes")
else:
    print("No")

top=0
sum=0
def sort(a,n):
    for i in range(n):
        sum=sum+a[i-1]
        if a[i-1]<a[i] or i==1:
            top=a[n-1]
asp=0
def am(m):
    asp=1-(1/(4*m))
    if top>sum*asp:
        print("No")
    else:
        print("Yes")

n,m=list(map(int,input().split()))
a=list(map(int,input().split()))

sort(a,n)
am(m)

top=0
sum=0
asp=0
n,m=list(map(int,input().split()))
a=list(map(int,input().split()))

for i in range(n):
    sum=sum+int(a[i-1])
    if a[i-1]<a[i] or i==1:
        top=int(a[i-1])

asp=float(1-(1/(4*m)))
asc=float((1/(4*m))
if top>sum*asp or top/asp>sum:
    print("No")
else:
    print("Yes")

n,m=map(int,input().split())
a=list(map(int,input().split()))

new_a=sorted(a,reverse=False)
sums=sum(a)

if new_a[0]>=sums/(m*4):
    print("Yes")
else:
    print("No")

n,m=map(int,input().split())
a=list(map(int,input().split()))

new_a=sorted(a)
sums=sum(a)

if new_a[m-1]>=sums/(m*4):
    print("Yes")
else:
    print("No")

top=0
sum=0
asp=0
n,m=list(map(int,input().split()))
a=list(map(int,input().split()))

for i in range(n):
    sum=sum+a[i-1]
    if a[i-1]<a[i] or i==1:
        top=a[n-1]
asp=1-(1/(4*m))
    if top>sum*asp:
        print("No")
    else:
        print("Yes")

n,m=map(int,input().split())
a=list(map(int,input().split()))

new_a=sorted(a)
sums=sum(a)

if new_a[0]>=sums/(m*4):
    print("Yes")
else:
    print("No")

n,m=(map(int,input().split()))
a=list(map(int,input().split()))

new_a=sorted(a,reverse=True)
sums=sum(a)

if new_a[m-1]>sums/(b*4):
    print("Yes")
else:
    print("No")

n,m=list(map(int,input().split()))
a=list(map(int,input().split()))

a=sorted(a)
sum=sum(a)/(4*m)

if a[m-1]>sum:
    print("Yes")
else:
    print("No")

n,m=list(map(int,input().split()))
a=list(map(int,input().split()))

sum=0
asp=float(1/(4*m))
a=sorted(a,key=lambda x: -x)
for i in range(n):
    sum=sum+int(a[i-1])

if int(a[0])>sum*asp:
    print("No")
else:
    print("Yes")

n,m=(map(int,input().split()))
a=list(map(int,input().split()))

b=sorted(a)
zyo=sum(b)/(4*m)

if b[m-1]>zyo:
    print("Yes")
else:
    print("No")

n,m=list(map(int,input().split()))
a=list(map(int,input().split()))

sum=0
asp=float(1/(4*m))
a=sorted(a,key=lambda x: -x)
for i in range(n):
    sum=sum+int(a[i-1])

if int(a[0])>sum*asp and int(a[1])>sum*asp:
    print("No")
else:
    print("Yes")

top=0
sum=0
def sort(a,n)
    for i in range(n):
        sum=sum+a[i-1]
        if a[i-1]<a[i] or i==1:
            top=a[n-1]
asp=0
def am(m):
    asp=1-(1/(4*m))
    if top>sum*asp:
        print("No")
    else:
        print("Yes")

n,m=list(map(int,input().split()))
a=list(map(int,input().split()))

sort(a,n)
am(m)

n,m=map(int,input().split())
a=list(map(int,input().split()))

new_a=sorted(a,reverse=True)
sums=sum(a)

if new_a[m-1]>=sums/(m*4):
    print("Yes")
else:
    print("No")

Verdicts: Runtime Error

Runtime Error

Runtime Error

Wrong Answer

Wrong Answer

Runtime Error

Wrong Answer

Runtime Error

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Runtime Error

Accepted