Problem:
 Score : 200 points    Problem Statement 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 .      Constraints  1 \leq M \leq N \leq 100  1 \leq A_i \leq 1000  A_i are distinct.  All values in input are integers.         Input Input is given from Standard Input in the following format:  N  M  A_1  ...  A_N       Output If M popular items can be selected, print Yes ; otherwise, print No .        Sample Input 1 4 1
5 4 2 1      Sample Output 1 Yes  There were 12 votes in total. The most popular item received 5 votes, and we can select it.       Sample Input 2 3 2
380 19 1      Sample Output 2 No  There were 400 votes in total. The second and third most popular items received less than \dfrac{1}{4\times 2} of the total number of votes, so we cannot select them. Thus, we cannot select two popular items.       Sample Input 3 12 3
4 56 78 901 2 345 67 890 123 45 6 789      Sample Output 3 Yes

Solution (Python):
n,m=map(int,input().split())
a=list(map(int,input().split()))
s=sum(a)
a.sort(reverse=True)
for i in range(m):
  if a[i]<s/(4*m):
    print('No')
    exit()
print('Yes')

Solution (Python):
import sys
input=lambda: sys.stdin.readline().rstrip()
n,m=map(int,input().split())
A=[int(i) for i in input().split()]
A.sort(reverse=True)
if A[m-1]>=sum(A)/(4*m):
  print("Yes")
else:
  print("No")

Solution (Python):
n, m = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
a.sort(reverse=1)
s = sum(a) / (4 * m)
if (4 * m)*a[m - 1] < sum(a):
    print("No")
else:
    print("Yes")

Solution (Python):

import sys
sys.setrecursionlimit(10**8)
INF = float("inf")


def yes():
    print("Yes")  


def no():
    print("No")  


def solve(N: int, M: int, A: "List[int]"):
    A.sort(reverse=True)
    if A[M-1] >= sum(A)/(4*M):
        yes()
    else:
        no()
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    M = int(next(tokens))  
    A = [int(next(tokens)) for _ in range(N)]  
    solve(N, M, A)


if __name__ == '__main__':
    main()

Solution (Python):
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 0, 1, -1, 1, -1, -1, 1]
dy = [1, -1, 0, 0, 1, -1, 1, -1]

n, m = MAP()
a = LIST()
s = sum(a)
a.sort(reverse=True)
t = s / 4 / m
if a[m - 1] >= t:
    print('Yes')
else:
    print('No')

Solution (Python):
import sys, bisect, math, itertools, string, queue, copy


from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush
from fractions import gcd

sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

def main():
    n,m = inpm()
    a = inpl()
    cnt = 0
    for i in range(n):
        if a[i] >= sum(a)/(4*m):
            cnt += 1
    if cnt >= m:
        print('Yes')
    else:
        print('No')
    
if __name__ == "__main__":
    main()

Solution (Python):
N,M = map(int,input().split())
A = list(map(int,input().split()))

cnt = 0
S = sum(A)
for i in A:
    if i >= S/(4*M):
        cnt += 1

if cnt >= M:
    print("Yes")
else:
    print("No")

Solution (Python):
n,m = map(int,input().split())
al = list(map(int,input().split()))

al = sorted(al, reverse=True)

k = al[m-1]

if k / sum(al) < 1 / (4 * m):
    print("No")
else:
    print("Yes")

Solution (Python):
import sys
n, m = [int(i) for i in sys.stdin.readline().split()]
a_ls = [int(i) for i in sys.stdin.readline().split()]
a_ls.sort(reverse=True)
if a_ls[m-1] < sum(a_ls) / 4 / m:
    print("No")
else:
    print("Yes")

Solution (Python):
N,M=map(int,input().split())
A=list(map(int,input().split()))
s=sum(A)
count=0
for i in range(0,N):
    if 4*M*A[i]>=s:
        count+=1

if count>=M:
    print('Yes')
else:
    print('No')

Solution (Python):



import array
from bisect import *
from collections import *
import fractions
import heapq
from itertools import *
import math
import random
import re
import string
import sys

N, M = map(int, input().split())
As = list(map(int, input().split()))
s = sum(As)
As.sort(reverse=True)

ok = True
for m in range(M):
    if As[m] * 4 * M >= s:
        pass
    else:
        ok = False
if ok:
    print('Yes')
else:
    print('No')

Solution (Python):











import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log 
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N,M=MI()
    A=LI()
    ans = 0
    need = sum(A)
    for a in A:
        if(need<=4*M*a):
            ans += 1
    if(ans>=M):
        print("Yes")
    else:
        print("No")
if __name__ == '__main__':
    main()

Solution (Python):

from collections import Counter
def inputlist(): return [int(k) for k in input().split()]

N,M = inputlist()
A = inputlist()
count = 0
s = sum(A)
for i in range(N):
    if A[i] >= s/(4*M):
        count +=1
if count >= M:
    print("Yes")
else:
    print("No")

Solution (Python):
n,m = map(int, input().split())
a = list(map(int, input().split()))
s = sum(a)
cnt = 0
for ai in a:
    if ai*4*m >= s:
        cnt += 1
if cnt >= m:
    print("Yes")
else:
    print("No")

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def main():
    n,m=MI()
    aa=LI()
    s=sum(aa)
    cnt=0
    for a in aa:
        if a*4*m>=s:cnt+=1
    if cnt>=m:print("Yes")
    else:print("No")

main()

Solution (Python):
import sys













readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    n, m = list(map(int, readline().split()))
    a = list(map(int, readline().split()))

    total = sum(a)

    cnt = 0

    for i in range(n):
        if a[i] >= (total / (4 * m)):
            cnt += 1

    if cnt >= m:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()

Solution (Python):



def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**6)
    

    def dump(*args):
        sys.stderr.write(str(args))

    n, m = map(int, input().split())
    a = list(map(int, input().split()))
    ans = 0
    s = sum(a)
    for i in a:
        if i >= s / 4 / m:
            ans += 1
    if ans >= m:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()

Solution (Python):
import sys
input = sys.stdin.readline

N, M = map(int, input().split())
A = list(map(int, input().split()))
total = sum(A)
cnt = 0
for a in A:
    if a * 4 * M >= total:
        cnt += 1
if cnt >= M:
    print('Yes')
else:
    print('No')

Solution (Python):



from math import *
from copy import *
from string import *				
from random import *				
from bisect import *				
from sys import stdin				
from sys import maxsize
from operator import *				
from itertools import *
from collections import Counter		
from collections import defaultdict 

'''

'''

def solve(l,m):
	f = 1
	n = len(l)
	tot = sum(l)
	k = tot/(4*m)
	l = sorted(l)[::-1][:m]
	for i in l:
		if(i < k):
			f = 0
			break
	if(f):
		return 'Yes'
	else:
		return 'No'

N,M = list(map(int, stdin.readline().rstrip().split()))
l = list(map(int, stdin.readline().rstrip().split()))
ans = solve(l,M)
print(ans)

Solution (Python):
def main():
    N, M = list(map(int, input().split()))
    A = list(map(int, input().split()))
    A.sort(reverse = True)
    S = sum(A)

    return A[M - 1] * 4 * M >= S

print('Yes' if main() else 'No')

Solution (Python):
N,M,*A=map(int, open(0).read().split())
S=sum(A)/(4*M)
print("YNeos"[not(sum(a>=S for a in A)>=M)::2])

Solution (Python):

from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.buffer.readline().split()]
def I(): return int(sys.stdin.buffer.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n,m = LI()
    a = LI()
    s = sum(a)
    k = 0
    for i in a:
        if 4*m*i < s:
            continue
        k += 1
    if k >= m:
        print("Yes")
    else:
        print("No")
    return


if __name__ == "__main__":
    solve()

Solution (Python):
n, m = map(int, input().split())
a = list(map(int, input().split()))
s = sum(a)
ans = 0
for x in a:
    if x * m * 4 >= s:
        ans += 1
if ans >= m:
    print('Yes')
else:
    print('No')