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



Sample input:
4 1
5 4 2 1


Sample output:
Yes

Submission status: Accepted

Solution code:
import sys
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
def resolve():
    N, M = lr()
    A = sorted(lr())[::-1]
    if A[M-1] < sum(A)/(4*M):
        print('No')
    else:
        print('Yes')
resolve()

Submission status: Accepted

Solution code:
import collections
import sys
import numpy as np
sys.setrecursionlimit(1000000000)

n,m = map(int,input().split())
a = list(map(int,input().split()))
toku = sum(a)
flag = toku*(1/(4*m))
cnt = 0
for i in range(len(a)):
    if a[i]>=flag:
        cnt += 1
if cnt >= m:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
a = [ int(x) for x in input().split() ]

s = sum(a)

cnt = 0
for aa in a:
    if 4 * aa * m >= s:
        cnt += 1

print("Yes" if cnt >= m else "No")

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
al = list(map(int, input().split()))
a_all = sum(al)
cnt = 0
for a in al:
    if a >= a_all/(4*m):
        cnt += 1

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

Submission status: Accepted

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

a.sort(reverse=True)
if a[m-1] < sum(a) / (4 * m):
    ans = "No"
else:
    ans = "Yes"

print(ans)

Submission status: Accepted

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

a = sorted(a, reverse=True)
all_vote = sum(a)

for i in range(m):
    if a[i] < all_vote * 0.25 / m:
        print("No")
        exit()
print("Yes")

Submission status: Accepted

Solution code:
# coding: utf-8

import sys
import math
import collections
import itertools
INF = 10 ** 10
MOD = 10 ** 9 + 7
def input() : return sys.stdin.readline().strip()
def gcd(x, y) : return y if x % y == 0 else gcd(y, x % y)
def lcm(x, y) : return (x * y) // gcd(x, y)
def I() : return int(input())
def LI() : return [int(x) for x in input().split()]
def RI(N) : return [int(input()) for _ in range(N)]
def LRI(N) : return [[int(x) for x in input().split()] for _ in range(N)]
def PL(L) : print(*L, sep="\n")

N, M = LI()
A = LI()

X = sum(A)

ans = 0
for a in A:
    if a >= X * (1/(4*M)):
        ans += 1

print("Yes" if ans >= M else "No")

Submission status: Accepted

Solution code:
import sys

input = sys.stdin.readline


def main():
    N, M = map(int, input().split())
    A = list(map(int, input().split()))
    sum_A = sum(A)

    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()

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
import math
YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(N: int, M: int, A: "List[int]"):
    criteria = math.ceil(sum(A)/(4*M))

    def check(n):
        return n >= criteria
    print(YES if len(list(filter(check, A))) >= M else NO)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, M, A)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
#JMD
#Nagendra Jha-4096

 
import sys
import math

#import fractions
#import numpy
 
###File Operations###
fileoperation=0
if(fileoperation):
    orig_stdout = sys.stdout
    orig_stdin = sys.stdin
    inputfile = open('W:/Competitive Programming/input.txt', 'r')
    outputfile = open('W:/Competitive Programming/output.txt', 'w')
    sys.stdin = inputfile
    sys.stdout = outputfile

###Defines...###
mod=1000000007
 
###FUF's...###
def nospace(l):
    ans=''.join(str(i) for i in l)
    return ans
 
 
 
##### Main ####
t=1
for tt in range(t):
    #n=int(input())
    n,m= map(int, sys.stdin.readline().split(' '))
    a=list(map(int,sys.stdin.readline().split(' ')))
    tot=sum(a)
    d=(tot//(4*m))
    if((tot%(4*m))!=0):
        d+=1
    c=0
    for num in a:
        if(num>=d):
            c+=1
    if(c>=m):
        print("Yes")
    else:
        print("No")
    
    
#####File Operations#####
if(fileoperation):
    sys.stdout = orig_stdout
    sys.stdin = orig_stdin
    inputfile.close()
    outputfile.close()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
A = list(map(int, input().split()))
total = sum(A)
cnt = 0
for a in A:
    if 4 * m * a < total:
        continue
    cnt += 1

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

Submission status: Accepted

Solution code:
n,m = map(int, input().split())
a = sorted(list(map(int, input().split())),reverse=True)
sum_a = sum(a)
ans = "Yes"
for i in a[:m]:
    if i * 4 * m < sum_a:
        ans = "No"
        break
print(ans)

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
A = list(map(int, input().split()))
A.sort(reverse=True)
goukei = sum(A)
cnt = 0
for a in A:
    if a * 4 * m >= goukei:
        cnt += 1
print("Yes" if cnt >= m else "No")

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
a = list(map(int, input().split()))
total = sum(a)
print('Yes' if len([v for v in a if v*4*m >= total]) >= m else 'No')

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

n,m = map(int,input().split())
A = list(map(int,input().split()))
S = sum(A)
for ai in A:
  if ai * 4 * m >= S:
    count += 1
if count >= m:
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
n , m = map(int, input().split())
ns = list(map(int, input().split()))
s = sum(ns)
ns = [i for i in ns if i >= s/(4*m)]
if len(ns) >= m:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
n,m = map(int,input().split())
a= list(map(int,input().split()))
a.sort()
total=sum(a)

if a[-m] >= total/(4*m):
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

sum_a = sum(a)
aa = sum_a / (m * 4)

count = 0
for i in a:
    if i >= aa:
        count += 1

print("Yes" if count >= m else "No")

Submission status: Accepted

Solution code:
n, m = map(int,input().split())
A = sorted(list(map(int,input().split())), reverse = True)
min_v = (1/(4*m)) * sum(A)
for a in A[:m]:
    if a < min_v:
        print('No')
        exit()
print('Yes')

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
a=list(map(int,input().split()))
x=sum(a)
ct=0
for i in range(n):
  if a[i]*4*m>=x:
    ct+=1
if ct>=m:
  print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().strip()


def main():
    n, m = map(int, input().split())
    A = list(map(int, input().split()))

    num = 0
    s = sum(A)
    for a in A:
        if a >= s / (m * 4):
            num += 1
    if num >= m:
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
A = sorted([int(x) for x in input().split()], reverse=True)
total = sum(A)
print('Yes' if A[m - 1] >= total / 4 / m else 'No')

Submission status: Accepted

Solution code:
def main():
    n, m = map(int, input().split())
    a = list(map(int, input().split()))
    a.sort(reverse=True)
    all_a = sum(a)
    count = 0
    for i in range(n):
        if all_a / (4 * m) <= a[i]:
            count += 1
        else:
            break
    print("Yes" if m <= count else "No")


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from sys import stdin
input = stdin.readline

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

A.sort(reverse=True)
a = sum(A)

for i in range(N):
    if A[i] < a / (4 * M):
        print("No")
        exit()

    if i >= M - 1:
        print("Yes")
        exit()

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
A = list(map(int, input().split()))
A.sort(reverse=True)
total = sum(A)
ans = 0
for a in A:
    if total <= a * (4 * M):
        ans += 1
if ans >= M:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
N,M = map(int,input().split())
*A, = map(int,input().split())

S = sum(A)
ans = 0
for a in A:
    if a*4*M>=S:
        ans += 1
if ans >= M:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
l = list(map(int, input().split()))
x = 1 / 4 / m
cnt = 0
s = sum(l)
for i in l:
	if i >= x * s:
		cnt += 1
if cnt >= m:
	print('Yes')
else:
	print('No')

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
A = list(map(int, input().split()))
A.sort(reverse=True)

sv = sum(A)
res = True
for i in range(M):
    if A[i] < sv/4/M:
        res = False
        break
if res:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
lists=list(map(int,input().split()))

lists=sorted(lists,reverse=True)
if lists[m-1]*4*m<sum(lists):
    print("No")
else:
    print("Yes")

Submission status: Accepted

Solution code:
n,m = map(int,input().split())
A = list(map(int,input().split()))
thres = sum(A)/(4*m)

A.sort(reverse = True)

for i in range(m):
  if A[i] < thres:
    print('No')
    break
else:
  print('Yes')

Submission status: Accepted

Solution code:
N,M = map(int, input().split())
A_list = [int(e) for e in input().split()]

OK_count = 0
for i in range(N):
  if A_list[i]>=sum(A_list)/(4*M):
  	OK_count+=1
    
if OK_count >= M:
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
# coding: utf-8
import re
import math
import itertools
from copy import deepcopy
import fractions
import random
from heapq import heappop,heappush
import time
import os
import sys
import datetime
from functools import lru_cache
readline=sys.stdin.readline
sys.setrecursionlimit(2000)
#import numpy as np
alphabet="abcdefghijklmnopqrstuvwxyz"
mod=int(10**9+7)
inf=int(10**20)
def yn(b):
    if b:
        print("yes")
    else:
        print("no")
def Yn(b):
    if b:
        print("Yes")
    else:
        print("No")
def YN(b):
    if b:
        print("YES")
    else:
        print("NO")
class union_find():
    def __init__(self,n):
        self.n=n
        self.P=[a for a in range(N)]
        self.rank=[0]*n
 
    def find(self,x):
        if(x!=self.P[x]):self.P[x]=self.find(self.P[x])
        return self.P[x]
 
    def same(self,x,y):
        return self.find(x)==self.find(y)
 
    def link(self,x,y):
        if self.rank[x]<self.rank[y]:
            self.P[x]=y
        elif self.rank[y]<self.rank[x]:
            self.P[y]=x
        else:
            self.P[x]=y
            self.rank[y]+=1
 
    def unite(self,x,y):
        self.link(self.find(x),self.find(y))
 
    def size(self):
        S=set()
        for a in range(self.n):
            S.add(self.find(a))
        return len(S)
def is_power(a,b):#aはbの累乗数か
    now=b
    while now<a:
        now*=b
    if now==a:return True
    else:return False
def bin_(num,size):
    A=[0]*size
    for a in range(size):
        if (num>>(size-a-1))&1==1:
            A[a]=1
        else:
            A[a]=0
    return A
def fac_list(n,mod_=0):
    A=[1]*(n+1)
    for a in range(2,len(A)):
        A[a]=A[a-1]*a
        if(mod>0):A[a]%=mod_
    return A
def comb(n,r,mod,fac):
    if(n-r<0):return 0
    return (fac[n]*pow(fac[n-r],mod-2,mod)*pow(fac[r],mod-2,mod))%mod
def next_comb(num,size):
    x=num&(-num)
    y=num+x
    z=num&(~y)
    z//=x
    z=z>>1
    num=(y|z)
    if(num>=(1<<size)):return False
    else:
        return num
def get_primes(n,type="int"):
    A=[True]*(n+1)
    A[0]=False
    A[1]=False
    for a in range(2,n+1):
        if A[a]:
            for b in range(a*2,n+1,a):
                A[b]=False
    if(type=="bool"):return A
    B=[]
    for a in range(n+1):
        if(A[a]):B.append(a)
    return B
def is_prime(num):
    if(num<=2):return False
    i=2
    while i*i<=num:
       if(num%i==0):return False
       i+=1
    return True
def ifelse(a,b,c):
    if a:return b
    else:return  c
def join(A,c=" "):
    n=len(A)
    A=list(map(str,A))
    s=""
    for a in range(n):
        s+=A[a]
        if(a<n-1):s+=c
    return s
#############################################

N,M=map(int,input().split())
A=list(map(int,input().split()))
cnt=0
all=sum(A)
for a in A:
    if a*4*M>=all:
        cnt+=1
Yn(cnt>=M)

Submission status: Accepted

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

sum_n = sum(a)

c = 0

for i in a:
    if i >= (1/(4*m))*sum_n:
        c += 1

if c >= m:
    print('Yes')

else:
    print('No')

Submission status: Accepted

Solution code:
N,M = map(int,input().split())
A = list(map(int,input().split()))
all_vote = sum(A)

cnt = 0
for i in range(N):
    if(A[i]>=all_vote/(4*M)):
        cnt += 1
if(cnt >= M):
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(N: int, M: int, A: "List[int]"):
    ALL = sum(A)
    A.sort(reverse=True)

    for i in range(M):
        if A[i] < ALL/(4*M):
            print(NO)
            return
    
    print(YES)

    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))  # type: int
    M = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, M, A)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

sum_A = sum(A)
A.sort(reverse=True)
x = sum_A/(4*M)
count = 0
for i in range(N):
    if A[i] >= x:
        count += 1
if count >= M:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
N,M=map(int,input().split())
la=list(map(int,input().split()))
suma=sum(la)
count=0
for a in la:
    if a>=suma/(4*M):
        count+=1
if count>=M:
    print('Yes')
else:
    print("No")

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
A = list(map(int, input().split()))
S = sum(A)
cnt = 0
for i in range(N):
  if 4 * M * A[i] >= S:
    cnt += 1
if cnt >= M:
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str

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

sum_a = sum(As)
judge = sum_a/(4*m)

cnt = 0
for a in As:
    if a >= judge:
        cnt += 1
if cnt >= m:
    print(YES)
else:
    print(NO)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline


def inpl():
    return list(map(int, input().split()))


N, M = inpl()
A = inpl()
sA = sum(A)
tmp = [a for a in A if sA <= 4 * M * a]
if len(tmp) >= M:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
N,M= map(int,input().split())
A = list(map(int,input().split()))
A.sort(reverse=True)

al = sum(A)
if A[M-1]*4*M >= al:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
n, m = list(map(int, input().split(' ')))
an = list(map(int, input().split(' ')))

limit = sum(an) / (4 * m)

count = 0
for i in range(n):
    if an[i] >= limit:
        count += 1


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

Submission status: Accepted

Solution code:
N,M = map(int,input().split())
A = [i for i in map(int,input().split())]

A.sort(reverse=True)
sumofvote = sum(A)
res = 0

for a in A:
  if a < (sumofvote/(4*M)):
    break
  else:
    res+=1
    
if res >= M:
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
a = list(map(int, input().split()))
a.sort(reverse = True)
if a[m - 1] * 4 * m >= sum(a):
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
A = list(map(int, input().split()))
sum_A = sum(A)

cnt = 0
for a in A:
    if a / sum_A >= 1 / (4 * M):
        cnt += 1
else:
    print('Yes' if cnt >= M else 'No')

Submission status: Accepted

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

wa = sum(a)
cnt = 0
for i in range(n):
    if a[i] >= wa / 4 / m:
        cnt += 1
if cnt >= m:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
import sys

def solve():
      input = sys.stdin.readline
      N, M = map(int, input().split())
      A = [int(a) for a in input().split()]
      A.sort(reverse = True)
      total = sum(A)
      for i in range(M):
            if A[i] * 4 * M < total:
                  print("No")
                  break
      else: print("Yes")

      return 0

if __name__ == "__main__":
      solve()

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
As = list(map(int, input().split()))

As.sort(reverse=True)
S = sum(As)
thre = S / (4 * M)

for i in range(M):
    if As[i] < thre:
        break
else:
    print('Yes')
    exit()
print('No')

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
a = list(map(int, input().split()))
mn = sum(a) / (4 * m)
cnt = 0
for i in range(n):
    if a[i] >= mn:
        cnt += 1
if cnt >= m:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
def main():
    N, M = (int(i) for i in input().split())
    A = [int(i) for i in input().split()]
    sumA = sum(A)
    C = [a >= sumA/(4*M) for a in A]
    print("Yes" if C.count(True) >= M else "No")


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    N, M = LI()
    A = LI()
    cnt = 0
    s = sum(A)
    for a in A:
        if a < s/(M*4):
            pass
        else:
            cnt += 1
    if cnt >= M:
        print('Yes')
    else:
        print('No')


main()

Submission status: Accepted

Solution code:
n, m  = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
sumer = sum(a)
ans = 0
for i in a:
    if i >= sumer / (4 * m):
        ans += 1

if ans >= m:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
l=list(map(int,input().split()))
l.sort(reverse=1)
s=sum(l)
if l[m-1]>=s/(4*m):print("Yes")
else:print("No")

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
a_list = list(map(int, input().split()))

a_list.sort()

total = sum(a_list)

mko = a_list[-m]

if mko * 4 * m >= total:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
inpl = lambda: list(map(int,input().split()))
N, M = inpl()
A = inpl()

A.sort(reverse=True)
S = sum(A)
if A[M-1] >= S/(4*M):
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
import sys
from collections import *
import heapq
import math
import bisect
from itertools import permutations,accumulate,combinations,product
from fractions import gcd
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]

n,m=map(int,input().split())
a=list(map(int,input().split()))
sou=sum(a)/4/m
ans=0
for i in range(n):
    if a[i]>=sou:
        ans+=1

# print(ans)
if ans>=m:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
MOD = 10 ** 9 + 7
INF = 10 ** 10
import sys
sys.setrecursionlimit(100000000)
dy = (-1,0,1,0)
dx = (0,1,0,-1)

def main():
    n,m = map(int,input().split())
    a = list(map(int,input().split()))
    tot = sum(a)
    a.sort(reverse = True)

    if a[m - 1] * 4 * m >= tot:
        print('Yes')
    else:
        print('No')

 
if __name__ =='__main__':
    main()

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
As = list(map(int, input().split()))

sumA = sum(As)

num = 0
for A in As:
    if A*4*M >= sumA:
        num += 1

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

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
A = [int(x) for x in input().split()]
total = sum(A)
threshold = total / 4 / M
A.sort()
for _ in range(M):
    if A.pop() < threshold:
        print('No')
        break
else:
    print('Yes')

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
A = list(map(int, input().split()))
S = sum(A)

cnt = 0
for a in A:
    if S / (4 * M) <= a:
        cnt += 1

ans = 'Yes' if cnt >= M else 'No'
print(ans)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(N: int, M: int, A: "List[int]"):
    summation = sum(A)
    count = 0
    for n in range(N):
        if A[n] >= summation * 1 / (4 * M):
            count += 1
    if count >= M:
        print(YES)
    else:
        print(NO)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, M, A)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
#!/usr/bin/env python
# coding: utf-8

def ri():
    return int(input())

def rl():
    return list(input().split())

def rli():
    return list(map(int, input().split()))

def check(s):
    for i in range(len(s)):
        if s[i] != s[len(s)-1-i]:
            return False
    return True

def main():
    n, m = rli()
    la = rli()
    la.sort(reverse=True)
    s = sum(la)
    if la[m-1]*4*m < s:
        print("No")
    else:
        print("Yes")


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import math
N,M= list(map(int,input().split(" ")))
nums = list(map(int,input().split(" ")))
s = sum(nums)
boder = s / (4 * M ) #これ以上なら選べる
cot = 0



for num in nums:
    if num >= boder:
        cot += 1

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

Submission status: Accepted

Solution code:
n,m = map(int,input().split())
A = list(map(int,input().split()))
ans = 0
t = sum(A)
for i in range(n):
    if A[i] < t/(4*m):
        None
    else:
        ans += 1
if ans >= m:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
n,m = map(int, input().split())
a = list(map(int, input().split()))
res = 0
for i in range(n):
  if a[i] >= sum(a)/(4*m):
    res += 1
if res >= m:
  print('Yes')
else:
  print('No')

Submission status: Accepted

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

sum_ = sum(a)
for i in range(n):
    a[i] *= (4 * m)
cnt = 0
for i in range(n):
    if a[i] >= sum_:
        cnt += 1
if cnt >= m:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
N,M = map(int,input().split())
A = [int(x) for x in input().split()]

cnt = 0
for i in range(N) :
    if A[i] >= sum(A) * 1 / (4*M) :
        cnt += 1

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

Submission status: Accepted

Solution code:
def main():
    N, M = map(int, input().split())
    A = list(map(int, input().split()))
    sum_A = sum(A)
    cnt = 0
    for a in A:
        if a >= (sum_A / (4 * M)): 
            cnt += 1

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


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline

n, m = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]

total = sum(a)

a.sort()
a = a[::-1]

a_m = a[m - 1]

if a_m * 4 * m >= total:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
n,m = map(int,input().split())
a = list(map(int,input().split()))
a.sort(reverse = True)

ans = sum(a)/(4*m)
if a[m-1] >= ans:
	print("Yes")
else:
	print("No")

Submission status: Accepted

Solution code:
#n = int(input())
#n,k = map(int,input().split())
#x = list(map(int,input().split()))

# print("Yes")
# print("No")

# print("YES")
# print("NO")


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

mm = sum(A)

cnt = 0
for i in range(N):
    if A[i] >= mm/(4*M):
        cnt += 1

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

Submission status: Accepted

Solution code:
n,m = map(int,input().split())
a  = list(map(int,input().split()))
s = sum(a)
res = 0
for i in range(n):
    if a[i] * 4*m >= s:res+=1
if res >= m:print('Yes')
else:print('No')

Submission status: Accepted

Solution code:
n,m = map(int,input().split())
arr = list(map(int,input().split()))

bod = sum(arr)/(4*m)

arr.sort(key=lambda x:-x)

flag = True
for i in range(m):
    if arr[i] < bod:
        flag = False


if flag:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
import sys
import itertools
import queue
import numpy as np
input = sys.stdin.readline
sys.setrecursionlimit(100000)
# mod = 10 ** 9 + 7

def read_values(): return map(int, input().split())
def read_index(): return map(lambda x: int(x) - 1, input().split())
def read_list(): return list(read_values())
def read_lists(N): return [read_list() for n in range(N)]


class V:
    def __init__(self, f, v=None):
        self.f = f
        self.v = v
 
    def __str__(self):
        return str(self.v)
 
    def ud(self, n):
        if n is None:
            return

        if self.v is None:
            self.v = n
            return
        self.v = self.f(self.v, n) 


def main():
    N, M = read_values()
    A = read_list()
    A.sort(reverse=True)
    S = sum(A)
    print("Yes" if A[M - 1] * M * 4 >= S else "No")


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
n,m = map(int,input().split())
a = list(map(int,input().split()))
a.sort()
s = sum(a)
b = s/(4*m)
if a[-m] >= b:
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

if __name__ == '__main__':
    solve()

Submission status: Accepted

Solution code:
import copy

import math
import fractions

def j(n):
    if n:print("Yes")
    else:print("No")
    exit(0)
rem = 10 ** 9 + 7

"""
def ct(x,y):
    if (x>y):print("+")
    elif (x<y): print("-")
    else: print("?")
"""

def ip():
    return int(input())
def iprow():
    return [int(i) for i in input().split()]
def ips():
    return (int(i) for i in input().split())
def ipmultiplerow(n):
    a = []
    for i in range(n):
        a.append(ip())
    return a
def printrow(a):
    for i in a:
        print(i)

def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

n,m = ips()
a = iprow()

s = sum(a)
a.sort(reverse= True)
for i in range(m):
    if a[i]  < s* (1/(4*m)): j(0)
j(1)

Submission status: Accepted

Solution code:
N,M = map(int,input().split())
A = list(map(int,input().split()))
X = sum(A)
print('Yes' if sum(4*M*a >= X for a in A)>=M else 'No')

Submission status: Accepted

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

Submission status: Accepted

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

S = sum(A)
A.sort(reverse=True)
print('Yes' if A[M - 1] >= S / (4 * M) else 'No')

Submission status: Accepted

Solution code:
[N,M] = list(map(int,input().split()))
A = list(map(int,input().split()))
L = sum(A)/(4*M)
A.sort(reverse=True)
out = "Yes"
for i in range(M):
    if A[i] <L:
        out = "No"
print(out)

Submission status: Accepted

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