Problem:


Score : 300 points

Problem Statement

Fennec is fighting with N monsters.

The health of the i-th monster is H_i.

Fennec can do the following two actions:

Attack: Fennec chooses one monster. That monster's health will decrease by 1.

Special Move: Fennec chooses one monster. That monster's health will become 0.

There is no way other than Attack and Special Move to decrease the monsters' health.

Fennec wins when all the monsters' healths become 0 or below.

Find the minimum number of times Fennec needs to do Attack (not counting Special Move) before winning when she can use Special Move at most K times.

Constraints

1 \leq N \leq 2 \times 10^5

0 \leq K \leq 2 \times 10^5

1 \leq H_i \leq 10^9

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N K
H_1 ... H_N

Output

Print the minimum number of times Fennec needs to do Attack (not counting Special Move) before winning.

Sample Input 1

3 1
4 1 5

Sample Output 1

5

By using Special Move on the third monster, and doing Attack four times on the first monster and once on the second monster, Fennec can win with five Attacks.

Sample Input 2

8 9
7 9 3 2 3 8 4 6

Sample Output 2

0

She can use Special Move on all the monsters.

Sample Input 3

3 0
1000000000 1000000000 1000000000

Sample Output 3

3000000000

Watch out for overflow.



Sample input:
3 1
4 1 5


Sample output:
5

Submission status: Accepted

Solution code:
a, b=map(int,input().split())
l=list(map(int,input().split()))
if a<=b:
  print(0)
elif a>b:
  l.sort(reverse=True)
  n=l[b:]
  s=sum(n)
  print(s)

Submission status: Accepted

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

if n<=m:
  print(0)
elif m==0:
  print(sum(a))
else:
  a=a[:-m]
  print(sum(a))

Submission status: Accepted

Solution code:
n,k = [int(x) for x in input().split()]
h = [int(x) for x in input().split()]
h.sort(reverse=True)
  
if(len(h) <= k):
	print("0")
else:
	print(sum(h[k:]))

Submission status: Accepted

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

h.sort()
ans = 0
for i in range(n-k):
    ans += h[i]
print(ans)

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
H = list(map(int,input().split()))


list.sort(H, reverse=True)

print(sum(H[K:]))

Submission status: Accepted

Solution code:
n, k = (int(i) for i in input().split())
h = [int(n) for n in input().split()]

h = sorted(h, reverse=True)

del h[:k]
sum = sum(h)

print(sum)

Submission status: Accepted

Solution code:
n,k = map(int,input().split())
m =  list(map(int,input().split()))
if n <= k :
    result = 0
else:
    m.sort()
    result = sum(m[:n-k])
    
print(result)

Submission status: Accepted

Solution code:
l1 = list(map(int, input().split()))
l2 = list(map(int, input().split()))

K = l1[1]
l2.sort(reverse=True)
print(sum(l2[K:]))

Submission status: Accepted

Solution code:
_, K = map(int, input().split())
v = list(map(int, input().split()))
v.sort()

if len(v) <= K:
  print(0)
elif K == 0:
  print(sum(v))
else:
  print(sum(v[:-K]))

Submission status: Accepted

Solution code:
input_num=[input() for i in range(2)]

n=input_num[0].split()
n=list(map(int,n))
a=input_num[1].split()
a=list(map(int,a))
     
if len(a)<=n[1]:
  print(0)
else:
  a.sort(reverse=True)
  b=a[n[1]:]
  print(sum(b))

Submission status: Accepted

Solution code:
N,K=map(int,raw_input().split())
H=map(float,raw_input().split())
H.sort(reverse=True)
ans = 0

for i in range(K,N):
  ans = ans + H[i]
if K>=N:
  print ans
else:
  print int(ans)

Submission status: Accepted

Solution code:
N,K = map(int,input().split())
H = sorted(list(map(int,input().split())))

rK = max(N-K, 0)
ans = sum(H[:rK])
print(ans)

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
h=list(map(int,input().split()))
h=sorted(h,reverse=True)
cnt=sum(h[k:])
print(cnt)

Submission status: Accepted

Solution code:
N,K=map(int,input().split())
A=[int(i) for i in input().split()]
A.sort(reverse=True)
B=A[K:]
cnt=0
for i in B:
  cnt+=i
print(cnt)

Submission status: Accepted

Solution code:
#!/user/bin/env python
#pythonプログラムであることを示している

# -*- coding: utf-8 -*-

def main():
    """
    ここでプログラムの解説を行う
     >>main()
    Hello world.
    0
    """
    s = list(map(int, input().split()))
    t = list(map(int, input().split()))
    t.sort(reverse=True)
    a = 0  #勝つまでの回数
    b = s[0]#何匹か
    d = s[1]#必殺技の回数
    f = 0# Maxのいち
    c = sum(t)
    for i in range(d):
        if c != 0:
            c -= t[i]
            t[i] = 0
        else:
            break
    a += sum(t)
    print(a)
    return 0

if __name__ == '__main__':

    #実際にmain()を呼び出して、結果を得て、その結果でPythonシステムを終える
    import sys
    sys.exit(main())

Submission status: Accepted

Solution code:
n,k = map(int,input().split())
h = list(map(int,input().split()))
h.sort()
ans = 0
for i in range(max(0,n-k)):
    ans += h[i]
print(ans)

Submission status: Accepted

Solution code:
N, K = (int(i) for i in input().split())
H = [int(i) for i in input().split()]
#Hを昇順にしてN-Kまでの配列を足し合わせて出力する
if N-K > 0:
    num = sum(sorted(H)[0:N-K])
else:
    num = 0
print(num)

Submission status: Accepted

Solution code:
N,K = map(int, input().split())
H = list(map(int, input().split()))

H.sort()
Sum = 0

for i in range(N-K):
    Sum += H[i]

print(Sum)

Submission status: Accepted

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

h.sort(reverse = True)
print(sum(h[k::]))

Submission status: Accepted

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

sorted_b = sorted(b,reverse=True)

print(sum(sorted_b[a[1]:a[0]]))

Submission status: Accepted

Solution code:
N,K = map(int,input().split())
A = sorted([int(i) for i in input().split()],reverse=True)
print(sum(A[K:]))

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
lst = sorted([int(x) for x in input().split()])
if K == 0:
    print(sum(lst))
else:
    print(sum(lst[:-K]))

Submission status: Accepted

Solution code:
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,pprint,fractions
sys.setrecursionlimit(10**8)
mod = 10**9+7
mod2 = 998244353
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n,k = inpl()
a = inpl()
a.sort(reverse=True)
res = 0
for i in range(n):
    if i < k:
        continue
    res += a[i]
print(res)

Submission status: Accepted

Solution code:
import heapq

n, k = map(int, input().split())
h = list(map(lambda x: int(x)*(-1), input().split()))

if n <= k:
    print(0)
    exit()

heapq.heapify(h)

for _ in range(k):
    heapq.heappop(h)

print(sum(h)*(-1))

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
h = list(map(int, input().split()))
h.sort()
t = 0
if n > k:
  for i in range(n - k):
    t += h[i]
print(t)

Submission status: Accepted

Solution code:
n,k = list(map(int,input().split()))
h=list(map(int,input().split()))
h.sort(reverse = True)
print(sum(h[k:]))

Submission status: Accepted

Solution code:
n,k = map(int, input().split())
h = sorted(list(map(int, input().split())))[::-1]
print(sum(h[k:]))

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
h=list(map(int,input().split()))
s=sorted(h)
if n<k:
  print(0)
  exit()
else:
  print(sum(s[0:n-k]))

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
h=list(map(int,input().split()))
s=sorted(h)
s.reverse()
print(sum(s[k:]))

Submission status: Accepted

Solution code:
#abc153c
n,k=map(int,raw_input().split())
h=map(int,raw_input().split())
h.sort(reverse=True)
if n<=k:
 print 0
else:
 print sum(h[k::])

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
*h, = map(int, input().split())

h.sort(reverse=True)
print(sum(h[k:]))

Submission status: Accepted

Solution code:
'''
8 9
7 9 3 2 3 8 4 6
'''
N, K = [int(x) for x in input().split()]
health = sorted([int(x) for x in input().split()])
print(sum(health[:max(0, N-K)]))

Submission status: Accepted

Solution code:
N, K = map(int, input().split(" "))
H = sorted(list(map(int, input().split(" "))))

if N <= K:
  print(0)
else:
  if K == 0:
    c = sum(H)
  else:
    c = sum(H[:-K])
  print(c)

Submission status: Accepted

Solution code:
import heapq
n,k = map(int, input().split())
h_list = list(map(int, input().split()))
print(sum(heapq.nsmallest(len(h_list)-k, h_list)))

Submission status: Accepted

Solution code:
x = input().split()
N, K = [int(i) for i in x]
H = input().split()
Hi = [int(j) for j in H]
Hi.sort(reverse=True)
num = Hi[K:]
print(sum(num))

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
H = list((sorted(map(int, input().split()))))

print(sum(H[:-K] if K != 0 else H))

Submission status: Accepted

Solution code:
N, K = (map(int,input().split()))
H = list(map(int,input().split()))
H.sort(reverse=True)
print(sum(H[K:]))

Submission status: Accepted

Solution code:
N,K = map(int, input().split())
H = [int(x) for x in input().split()]
H.sort(reverse=True)
del H[0:K]
print(sum(H))

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
a = sorted(map(int, input().split()), reverse=True)
print(sum(a[i] for i in range(k, n)))

Submission status: Accepted

Solution code:
# = int(input())
# = map(int, input().split())
# = list(map(int, input().split()))
# = list(input())
# = [tuple(map(int, input().split())) for _ in range(n)]

n, k = map(int, input().split())
h = list(map(int, input().split()))

h.sort(reverse=True)

if k >= n:
    print(0)
else:
    print(sum(h[k:]))

Submission status: Accepted

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

monsters.sort(reverse=True)

print(sum(monsters[K:]))

Submission status: Accepted

Solution code:
#input
N, K = map(int, input().split())
H = list(map(int, input().split()))

#output
H.sort()
answer = 0
if K >= N:
    answer = 0
else:
    answer += sum(H[0:(N-K)])

print(answer)

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
H = list(map(int, input().split()))
H.sort(reverse=True)
print(sum(H[k:]) if n>k else 0)

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
h = sorted(map(int, input().split()))
if k:
    h = h[0:-k]
print(sum(h))

Submission status: Accepted

Solution code:
H, N = map(int, input().split())
A = [int(x) for x in input().split()]
list2 = sorted(A, reverse=True)  # reverseをTrueに

if N>H:
    print(0)
elif N>0:
    del list2[0:N]
    print(sum(list2))
elif N<=0:
    print(sum(A))

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
H = list(map(int, input().split()))

H.sort(reverse=True)

if K >= N:print(0)
else:
    print(sum(H[K:N]))

Submission status: Accepted

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


h.sort(key=None, reverse=True)
print(sum(h[k:]))

Submission status: Accepted

Solution code:
# C - Fennec vs Monster
def main():
    N, K, *H = map(int, open(0).read().split())
    need_attacks = sorted(H, reverse=True)[K:]
    print(sum(need_attacks))


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
H = list(map(int, input().split()))
H.sort()
for _ in range(min(N, K)):
    H.pop()
print(sum(H))

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
h = sorted(list(map(int, input().split())))

if n <= k:
    print(0)
    exit()

cnt = 0
for i in range(n - k):
    cnt += h[i]
print(cnt)

Submission status: Accepted

Solution code:
N,K = map(int,input().split())

H = sorted([int(x) for x in input().split()],reverse = True)

print(sum(H[K:]))

Submission status: Accepted

Solution code:
N,K=map(int,input().split())
H=list(map(int,input().split()))
H.sort()
H.reverse()
print(sum(H)-sum(H[0:K]))

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
Hn = list(map(int, input().split()))

ans = 0
Hn = sorted(Hn)
for i in range(N-K):
    ans += Hn[i]

print(ans)

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
h = sorted(list(map(int, input().split())))
ans = sum(h) if k == 0 else sum(h[:-k])
print(ans)

Submission status: Accepted

Solution code:
N,K = map(int, input().split())
T = list(map(int, input().split()))
T.sort()
if K>=N:
    print(0)
else:
    for i in range(K):
        T.pop()
    
    print(sum(T))

Submission status: Accepted

Solution code:
m,n=map(int,input().split())
l=list(map(int,input().split()))
if len(l)==m:
  l.sort()
  if n<=m:
    for i in range(n):
      l.pop()
    print(sum(l))
  else:
    print(0)
else:
  print(0)

Submission status: Accepted

Solution code:
from sys import stdin

n, k = (int(v) for v in stdin.readline().split())
monsters = [int(v) for v in stdin.readline().split()]


if len(monsters) <= k:
    print("0")
else:
    monsters = sorted(monsters)
    monsters = monsters[:-k] if k > 0 else monsters
    print(sum(monsters))

Submission status: Accepted

Solution code:
n,k = map(int,input().split())
arr = list(map(int,input().split()))
arr.sort(reverse=True)
if k >= n :
  print(0)
elif k == 0 :
  print(sum(arr))
else :
	for i in range(k) :
		arr[i] = -1
	sum = 0
	for i in arr :
		if i!=-1 :
			sum+=i

	print(sum)

Submission status: Accepted

Solution code:
n,k = map(int,input().split())
lis = list(map(int,input().split()))
lis.sort(reverse=True)
ans = 0
for i in range(n):
  if k > 0:
    k -= 1
  else:
    ans += lis[i]
print(ans)

Submission status: Accepted

Solution code:
s = [list(map(int,input().split())) for i in range(2)]
t = s[0]
N = t[0]
K = t[1]
H = s[1]
if K > N:
    print(0)
else:
    H.sort()
    H[N - K:N]=[]
    print(sum(H))

Submission status: Accepted

Solution code:
input_line = list(map(int,input().split()))
input_hp = list(map(int,input().split()))

if input_line[0] <= input_line[1]:
    print('0')
else:
    input_hp.sort()
    result_input_hp = len(input_hp) - input_line[1]
    sum_total = sum(input_hp[:result_input_hp])
    print(sum_total)

Submission status: Accepted

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

h.sort()
s = 0

for i in range(n - k):
    s += h[i]

print(s)

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
 
list_monster = list(map(int, input().split()))
list_monster.sort(reverse = True) 
 
if N <= K:
  print(0)
  
elif K == 0:
  print(sum(list_monster))
  
else:
  print(sum(list_monster[K:]))

Submission status: Accepted

Solution code:
[n,k]=[int(x) for x in input().split()]
h=[int(x) for x in input().split()]
h.sort()
if n<=k:
  print("0")
else:
  print(str(sum(h[:len(h)-k])))

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
list=input().split()
list=[int(x)for x in list]
list.sort(reverse=True)
list=list[k:]
print(sum(list))

Submission status: Accepted

Solution code:
n,k = map(int,input().split())
h = list(map(int,input().split()))
h = sorted(h,reverse=True)
cnt = 0
if k>n:
    print(0)
else:
    for i in range(k):
        h[i] = 0
    for i in range(len(h)):
        cnt+=h[i]
    print(cnt)

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
if n==0:
  print(0)
else:
  c=sorted(list(map(int,input().split())))
  if k>=n:
    print(0)
  else:
    print(sum(c[:n-k]))

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
l=list(map(int,input().split()))
l.sort()
if k>=n:
    print(0)
else:
    print(sum(l[:n-k]))

Submission status: Accepted

Solution code:
import sys

def propare():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))
    K = int(next(tokens))
    H_list = []
    for i in range(N):
        H_list.append(int(next(tokens)))

    solve(N, K, H_list)

def solve(H: int, N: int, H_list: list):
    H_ranking_list = sorted(H_list, reverse=True)
    H_ranking_list = H_ranking_list[N:]

    count = sum(H_ranking_list)

    print(count)

    return
 
if __name__ == "__main__":
    propare()

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
if(n<=k):
  print(0)
  exit()

H=list(map(int,input().split()))
H.sort()
print(sum(H[:n-k]))

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
H = [int(x) for x in input().split()]
H.sort(reverse=True)
print(sum(H[K:]))

Submission status: Accepted

Solution code:
'''input
3 0
1000000000 1000000000 1000000000
'''
from sys import stdin
input = stdin.readline

def get_me():
	return []


# main starts
n, k = list(map(int, input().split()))

arr  = list(map(int, input().split()))

arr.sort(reverse = True)

l = len(arr)
count = 0
while l > k:
	count += arr[-1]
	arr.pop()
	l -= 1

print(count)

Submission status: Accepted

Solution code:
def main():
    N, K = [int(x) for x in input().split()]
    hs = [int(x) for x in input().split()]
    hs = sorted(hs, reverse=True)
    if K >= N:
        print(0)
    else:
        hs = hs[K:]
        print(sum(hs))


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n,k = map(int, input().split(' '))
h = list(map(int, input().split(' ')))
h.sort()

# print(n)
# print(k)
# print(h)

s = 0

i = 0
while i < n-k:
  s += h[i]
  i += 1

print(s)

Submission status: Accepted

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

l= list(map(int,input().split()))
l.sort()
i=k-1
sum=0
for i in range (n-k):
    sum=sum+l[i]
print(sum)

Submission status: Accepted

Solution code:
# coding: utf-8
from fractions import gcd 
from functools import reduce
# my functions here!
def pin(type=int):
    return map(type,input().split())
#input
N,K =pin()
H = list(pin())
#solution
H.sort()
#print(H)
ans=0
if N > K:
    for i in range (K):
        H.pop()
    print(sum(H))
else:
    print(0)
#output
#print(ans)

Submission status: Accepted

Solution code:
from heapq import heappush,heappop,heapify
from collections import deque,defaultdict,Counter
import itertools
from itertools import permutations,combinations,groupby
import sys
import bisect
import string
import math
import time
import random
def S_():
    return input()
def LS():
    return [i for i in input().split()]
def I():
    return int(input())
def MI():
    return map(int,input().split())
def LI():
    return [int(i) for i in input().split()]
def LI_():
    return [int(i)-1 for i in input().split()]
def NI(n):
    return [int(input()) for i in range(n)]
def NI_(n):
    return [int(input())-1 for i in range(n)]
def StoI():
    return [ord(i)-97 for i in input()]
def ItoS(nn):
    return chr(nn+97)
def LtoS(ls):
    return ''.join([chr(i+97) for i in ls])
def GI(V,E,Directed=False,index=0):
    org_inp=[]
    g=[[] for i in range(n)]
    for i in range(E):
        inp=LI()
        org_inp.append(inp)
        if index==0:
            inp[0]-=1
            inp[1]-=1
        if len(inp)==2:
            a,b=inp
            g[a].append(b)
            if not Directed:
                g[b].append(a)
        elif len(inp)==3:
            a,b,c=inp
            aa=(inp[0],inp[2])
            bb=(inp[1],inp[2])
            g[a].append(bb)
            if not Directed:
                g[b].append(aa)
    return g,org_inp
def GGI(h,w,search=None,replacement_of_found='.',mp_def={'#':1,'.':0}):
#h,w,g,sg=GGI(h,w,search=['S','G'],replacement_of_found='.',mp_def={'#':1,'.':0}) # sample usage
    mp=[1]*(w+2)
    found={}
    for i in range(h):
        s=input()
        for char in search:
            if char in s:
                found[char]=((i+1)*(w+2)+s.index(char)+1)
                mp_def[char]=mp_def[replacement_of_found]
        mp+=[1]+[mp_def[j] for j in s]+[1]
    mp+=[1]*(w+2)
    return h+2,w+2,mp,found
def bit_combination(k,n=2):
    rt=[]
    for tb in range(n**k):
        s=[tb//(n**bt)%n for bt in range(k)]
        rt+=[s]
    return rt
def show(*inp,end='\n'):
    if show_flg:
        print(*inp,end=end)
YN=['Yes','No']
mo=10**9+7
inf=float('inf')
l_alp=string.ascii_lowercase
u_alp=string.ascii_uppercase
ts=time.time()
sys.setrecursionlimit(10**7)
input=lambda: sys.stdin.readline().rstrip()

def ran_input():
    import random
    n=random.randint(4,16)
    rmin,rmax=1,10
    a=[random.randint(rmin,rmax) for _ in range(n)]
    return n,a

show_flg=False
show_flg=True

ans=0

n,k=LI()
h=sorted(LI())
ans=sum(h[:max(0,n-k)])

print(ans)

Submission status: Accepted

Solution code:
f=lambda:map(int,input().split())
n,k=f()
print(sum(sorted(list(f()))[:max(n-k,0)]))

Submission status: Accepted

Solution code:
m, n = map(int, input().split())
li = list(map(int, input().split()))
if n >= m:
  print(0)
elif n == 0:
  print(sum(li))
else:
  print(sum(sorted(li)[:-n]))

Submission status: Accepted

Solution code:
#!/user/bin/env python
#pythonプログラムであることを示している

# -*- coding: utf-8 -*-

def main():
    """
    ここでプログラムの解説を行う
     >>main()
    Hello world.
    0
    """
    s = list(map(int, input().split()))
    t = list(map(int, input().split()))
    t.sort(reverse=True)
    a = 0  #勝つまでの回数
    b = s[0]#何匹か
    d = s[1]#必殺技の回数
    f = 0# Maxのいち
    # for j in range(d):  #必殺技の回数
    #     c = sum(t)
    #     if c != 0:
    #         g = max(t)
    #         for i in range(b):
    #             if g == t[i]:
    #                 t[i] = 0
    #                 break
    #         t[f] = 0
    #         f = 0
    #     else:
    #         break
    c = sum(t)
    for i in range(d):
        if c != 0:
            c -= t[i]
            t[i] = 0
        else:
            break
    a += sum(t)
    print(a)
    return 0

if __name__ == '__main__':

    #実際にmain()を呼び出して、結果を得て、その結果でPythonシステムを終える
    import sys
    sys.exit(main())

Submission status: Accepted

Solution code:
f = lambda:map(int,input().split())
n, k = f()
l = sorted(list(f()))
k = min(k,n)
print(sum(l[:n-k]))

Submission status: Accepted

Solution code:
n,k = map(int,input().split())
h = [int(x) for x in input().split()]
h.sort()
if k>=n:
  print("0")
else:
  print(sum(h[:n-k]))

Submission status: Accepted

Solution code:
N,K = [int(number) for number in input().split()]
H = [int(number) for number in input().split()]
H.sort()
if N <= K:
  print("0")
else:
  print(sum(H[:N-K]))

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
h = sorted(list(map(int, input().split())), reverse=True)
print(sum(h[k:]) if k < n else 0)

Submission status: Accepted

Solution code:
N,K = map(int,input().split())
H = sorted(list(map(int,input().split())))

if K >= N:
  print(0)
elif K == 0:
  print(sum(H))
else:
  print(sum(H[:-K]))

Submission status: Accepted

Solution code:
# -*- coding:utf-8 -*-

n,k = map(int, input().strip().split())
h = list(map(int, input().strip().split()))

h.sort(reverse=True)
count = 0
for i in range(k, n):
  count += h[i]
print(count)

Submission status: Accepted

Solution code:
nk = [int(s) for s in input().split()]
n, k = nk[0], nk[1]
arr = [int(s) for s in input().split()]
if k >= n:
    print(0)
else:
    arr.sort()
    print(sum(arr[:n-k]))

Submission status: Accepted

Solution code:
import math


N,K = map(int,input().split())

K = min(N,K)


data = list(map(int,input().split()))

data.sort()

total = sum( data[0:N-K] )


print(total)

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
H = sorted(list(map(int, input().split())), reverse=True)
print(sum(H[K:]))

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
*H, = sorted(map(int, input().split()), reverse=True)
print(sum(H[K:]))

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
h=list(map(int,input().split()))
h.sort()

if n<=k:
    print(0)
else:
    print(sum(h[:n-k]))

Submission status: Accepted

Solution code:
H,K = map(int,input().split())
Monster = list(map(int,input().split()))

if H<=K:
    print(int(0))
else:
    KK = 0
    KK =int(K)
    ReMonster = 0
    list.sort(Monster,reverse= True)
    del Monster[0:KK]
    print(sum(Monster[:]))

Submission status: Accepted

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

h.sort()

if k > n:
    print(0)
    exit()

for i in range(k):
    h[n-i-1] = 0

s = sum(h)

print(s)

Submission status: Accepted

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

a.sort(reverse=True)


print(sum(a[n:]))

Submission status: Accepted

Solution code:
n,k = map(int,input().split())
h=list(map(int,input().split()))
h.sort()
if n<=k:
    print(0)
else:
    print(sum(h[:n-k]))

Submission status: Accepted

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

h_n = list(map(int, input().split()))

if n <= k:
    print("0")
else:
    print(sum(sorted(h_n)[:n - k]))

Submission status: Accepted

Solution code:
N,K = map(int,input().split())
L = list(map(int,input().split()))
L.sort()
count = K
ans = 0
if len(L)>K:
  for i in range(len(L)-K):
    ans += L[i]
  print(ans)
else:
  print(0)

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
H = sorted(list(map(int, input().split())))
if n <= k:
  print(0)
else:
  print(sum(H[:n-k]))

Submission status: Accepted

Solution code:
def f(h,k):
    N=len(h)
    t=0
    h.sort()
    for i in range(N-k):
        t+=h[i]
    return t
N,k=map(int,input().split())
h=list(map(int,input().split()))
print(f(h,k))

Submission status: Accepted

Solution code:
import math

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

h_n = list(map(int, input().split()))

if n <= k:
    print("0")
else:
    s_n = sorted(h_n)

    print(sum(s_n[:n-k]))

Submission status: Accepted

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

h = list(map(int, input().split( )))

h.sort()
if len(h)<k:
    print(0)
else:
    print(sum(h[:len(h)-k]))

Submission status: Accepted

Solution code:
a,b = map(int,input().split())
arr = list(map(int,input().split()))
arr.sort(reverse = True)
if b>=a:
    print(0)
else:
    print(sum(arr[b:]))

Submission status: Accepted

Solution code:
N,K = map(int,input().split())
H = [int(x) for x in input().split()]
#print(H)
H.sort()
#print(H)
Ans = 0
for x in range(0,min(K,N)):
#    print(x)
    H.pop()
#print(H)
for x in H:
    Ans = x+Ans
print(Ans)

Submission status: Accepted

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

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n,k = LI()
h = LI()
h.sort(reverse=1)
ans = sum(h[min(n,k):])
print(ans)

Submission status: Accepted

Solution code:
import heapq

N,K = (int(x) for x in input().split())
H = list((-1)*(int(x)) for x in input().split())
heapq.heapify(H)
count = 0

for _ in range(K):
    if len(H) == 1:
        print(0)
        break

    heapq.heappop(H)
    count += 1

if len(H) != 1:
    sum = 0
    for _ in range(len(H)):
        sum -= heapq.heappop(H)

    print(sum)

elif len(H) == 1 and K == count:
    print(-heapq.heappop(H))

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
h = sorted(list(map(int, input().split())), reverse=True)

res = sum(h[k:])

print(res)

Submission status: Accepted

Solution code:
import sys
import math
import itertools
N,K=map(int,input().split())
H=list(map(int,input().split()))
H.sort(reverse=True)
total=0
for i in range(N):
    if i>K-1:
        total+=H[i]
print(total)

Submission status: Accepted

Solution code:
import sys

read = sys.stdin.read

N, K, *H = map(int, read().split())
H.sort(reverse=True)

if N <= K:
    print(0)
else:
    print(sum(H[K:]))

Submission status: Accepted

Solution code:
n,k = map(int,input().split())
h = list(map(int,input().split()))
h.sort()
ans = int(0)
for i in range(len(h) - k):
    ans += int(h[i])
print(ans)

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
h=list(map(int,input().split()))
h.sort(reverse=True)
if n<=k:
  print(0)
else:
  print(sum(h[k:n]))

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
H = list(map(int, input().split()))

# N monsters
# No.i monster vitalitiy is Hi
# two actions
# attack : reduce 1 vitaility
# special: make vitality 0. Fenek can use K times of specials.

# print(H)
# print(f'N={N} K={K}')
if N <= K:
    print(0)
    exit()


H.sort(reverse=True)
# print(H)


r_H = H[K:]
# print(r_H)
# print(sum(r_H))

sum_H = 0
for hp in r_H:
    sum_H += hp
print(sum_H)

# print(type(10**9))
# print(type(2*10**14))

Submission status: Accepted

Solution code:
import math

N, K = map(int, input().split())
H = list(map(int, input().split()))

H.sort()
if K == 0:
    print(sum(H))
elif K >= N:
    print(0)
else:
    H = H[:-K]
    print(sum(H))

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
h = list(map(int, input().split()))
h = sorted(h, reverse=True)
ans = 0
for i in range(k, n):
  ans+=h[i]
  
print(ans)

Submission status: Accepted

Solution code:
def c_fennec_vs_monster():
    N, K = [int(i) for i in input().split()]
    H = sorted([int(i) for i in input().split()])
    return sum(H[:N - min(K, N)])

print(c_fennec_vs_monster())

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
H = list(map(int, input().split()))

# N monsters
# No.i monster vitalitiy is Hi
# two actions
# attack : reduce 1 vitaility
# special: make vitality 0. Fenek can use K times of specials.

# print(H)
# print(f'N={N} K={K}')
if N <= K:
    print(0)
    exit()


H.sort(reverse=True)
# print(H)


r_H = H[K:]
# print(r_H)

# for hp in r_H:
#     sum_H += hp

print(sum(r_H))
# print(type(10**9))
# print(type(2*10**14))

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
h = list(map(int, input().split()))
h = sorted(h, reverse=True)
ans = 0
for i in range(k, n):
  ans+=h[i]
  
print(ans)

Submission status: Accepted

Solution code:
# coding: utf-8
bodies_count = list(map(int,input().split()))
enemy_life = list(map(int,input().split()))

if bodies_count[1] == 0:
    print(sum(enemy_life))
else:
    enemy_life.sort(reverse=True)
    if bodies_count[1] == 1:
        del enemy_life[0] 
    else:
        a = bodies_count[1]
        del enemy_life[0:a]

    if enemy_life != []:
        print(sum(enemy_life))
    else:
        print(0)
    # for i in range(bodies_count[1]):
    #     if enemy_life == []:
    #         print(count)
    #         break
    #     else:
    #         enemy_life.sort()
    #         print(enemy_life)
    #         enemy_life.pop(enemy_life.index(max(enemy_life)))

Submission status: Accepted

Solution code:
n, k = list(map(int, input().rstrip().split()))
h = list(map(int, input().rstrip().split()))
h.sort()
print(sum(h[:max(0, n-k)]))

Submission status: Accepted

Solution code:
n,k,*h=map(int,open(0).read().split())
print(sum(sorted(h)[:n-min(n,k)]))

Submission status: Accepted

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


if N <= K:
    print(0)

elif K == 0:
    print(sum(H))

else:
    H.sort()
    H.reverse()
    print(sum(H[K:N]))