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:
n,k = list(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())
H=list(map(int,input().split()))

H.sort()
H.reverse()
del H[:k]
a=sum(H)
print(a)

Submission status: Accepted

Solution code:
num = input().split(" ")
monster = int(num[0])
atk = int(num[1])
hpoints = list(input().split(" "))
hpoints_i = [int(i) for i in hpoints]

hpoints_i.sort(reverse=True)

result = sum(hpoints_i[atk:])
print(result)

Submission status: Accepted

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

Submission status: Accepted

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

if k >= len(h_list):
    print(0)
else:
    h_list.sort(reverse=True)
    h_list = h_list[k:]
    print(sum(h_list))

Submission status: Accepted

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

Submission status: Accepted

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

H.sort(reverse=True)

del H[0:k]
print(sum(H))

Submission status: Accepted

Solution code:
N, K = map(int, input().rstrip().split())
a = sorted(list(map(int, input().split())), reverse=True)
ans = 0

for i, x in enumerate(a):
    if i >= K:
        ans += x
        
print(ans)

Submission status: Accepted

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

count = 0

if N < K:
    K = N

for i in range(K):
    H_list.pop(-1)

count += sum(H_list)

print(str(count))

Submission status: Accepted

Solution code:
x = input().split()
n = int(x[0])
k = n if n < int(x[1]) else int(x[1])

h = input().split()
h = [int(i) for i in h]
h.sort(reverse=True)

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

print(sum(h))

Submission status: Accepted

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

Submission status: Accepted

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

h.sort()

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

Submission status: Accepted

Solution code:
def main():
    N, K = map(int, input().split())
    H = sorted(list(map(int, input().split())), reverse=True)
    all = sum(H)
    at = 0
    if (K > N):
        K = N
    for i in range(K):
        at += H[i]
    result = all - at
    if result <= 0:
        result = 0
    print(result)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a,b= map(int, input().split())
S=list(map(int, input().split()))
import numpy as np
SS=np.sort(S)
Sum=0
for i in range(a-b):
    Sum=Sum+SS[i]
print(Sum)

Submission status: Accepted

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

H_sorted = sorted(H, reverse=True)

print(sum(H_sorted[K:]))

#print(H_sorted)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    n, k = [int(x) for x in input().split()]
    h = [int(x) for x in input().split()]
    nk = n-k
    if nk < 0:
        nk = 0
    at = sorted(h)[:nk]
    print(sum(at))

if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
H = sorted([int(x) for x in input().split()])
#print(H)

if N<K:
	K=N

for i in range(K):
	H.pop((N-1)-i)

#print(H)

print(sum(H))

Submission status: Accepted

Solution code:
s = input().split()
n, k = int(s[0]), int(s[1])
 
ss = input().split()
l = [int(i) for i in ss]
 
l.sort()
if n < k:
  print(0)
elif k == 0:
  print(sum(l))
else:
  print(sum(l[:n-k]))

Submission status: Accepted

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

arr = sorted(arr,reverse=True)
arr[:min(n,k)] = [0]*min(n,k)

print(sum(arr))

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,K=map(int,input().split())
ar= list(map(int, input().split()))
ans=0
ar.sort()

if N<=K:
    print(ans)
else:
    for i in range(1,K+1):
        f=-1*i
        ar[f]=0

    for i in range(N):
        ans+=ar[i]

    print(ans)

Submission status: Accepted

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

if (n<=k):
  print(0)
elif (k==0):
  print(sum(lst))
else:
  sum_count = sum(lst[:-k])
  print(sum_count)

Submission status: Accepted

Solution code:
n,k=map(int, input().split())
l=list(map(int, input().split()))
if k>=n:
    print("0")
    exit(0)

l.sort()

sum=0
for i in range(n-k):
    sum=sum+l[i]

print(sum)

Submission status: Accepted

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

Submission status: Accepted

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

h.sort(reverse=True)

min = 0

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

else:
    for i in range(k):
        h[i] = 0
    print(sum(h))

Submission status: Accepted

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

h = [int(x) for x in input().split()]

if len(h) <= k:
    print(0)
else:
    sorted_h = sorted(h, reverse=True)
    print(sum(sorted_h[k:]))

Submission status: Accepted

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

list.sort()

i=0
m=0
r=0

while(i<n-k):
  m+=list[i]
  i+=1

print(m)

Submission status: Accepted

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

if K == 0:
    print(sum(List))
    exit()

if N <= K:
    print('0')
    exit()

List.sort(reverse=True)
del List[:K]

print(sum(List))

Submission status: Accepted

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

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

h.sort()

if k != 0:
  A = sum(h[:-k])
else:
  A = sum(h)


if A > 0:
  print(A)
else:
  print(0)

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:
    H=H[:(N-K)]
    print(sum(H))

Submission status: Accepted

Solution code:
dummy = list(map(int, input().split(" ")))
N = dummy[0]
K = dummy[1]

H = list(map(int, input().split(" ")))

H.sort(reverse = True)

for i in range(N):
    if(i < K):
        H[i] = 0

print(sum(H))

Submission status: Accepted

Solution code:
# coding: utf-8

n, k = map(int, input().split())
hlist = list(map(int, input().split()))
nlist = sorted(hlist, reverse=True)
del nlist[0:k]
total = sum(nlist)
print(total)

Submission status: Accepted

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

H = sorted(H)[::-1]

cnt = 0
for i in range(N):
    if K > 0:
        K -= 1
    else:
        cnt += H[i]

print(cnt)

Submission status: Accepted

Solution code:
NK = input().split()
N = int(NK[0])
K = int(NK[1])

sum = 0

H = []
tmp = input().split()
for i in range(N):
	H.append(int(tmp[i]))

  
H.sort() 
for i in range(K):
  try:
    H.pop()
  except IndexError:  
    pass

sum = 0  
  
for i in H:
  sum += i

print(sum)

Submission status: Accepted

Solution code:
N,K=map(int,input().split())
H=list(map(int,input().split()))
H.sort()
if K>=N:
  print(0)
elif K==0:
  print(sum(H))
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.sort()
for i in range(K):
    if len(H) > 0:
        H.pop()
    else:
        H.append(0)
print(sum(H))

Submission status: Accepted

Solution code:
HK = list(map(int,input().split(" ")))
HP = list(map(int,input().split(" ")))
H = HK[0]
K = HK[1]
HP.sort(reverse=True)
sum_a = sum(HP[K:])
print(sum_a)

Submission status: Accepted

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

Submission status: Accepted

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

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())
l=list(map(int,input().split()))
l.sort(reverse=True)
sum=0
for i in range(k,n):
    sum+=l[i]
print(sum)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
li = list(map(int, input().split()))
li_a = sorted(li)
if k == 0:
  print(sum(li_a))
elif k >= n:
  print(0)
else:
  for i in range(k):
    li_a.pop()
  print(sum(li_a))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import numpy as np

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

if N > K != 0:
    H_array = np.array(H).reshape(-1)

    H_array_sorted = np.sort(H_array)

    H_remain = H_array_sorted[:(N - K)]

    H_sum = np.sum(H_remain)

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import numpy as np
N,K=map(int,input().split())
H_list=[float(H) for H in input().split()]
H_sort=np.sort(H_list)
if K==0:
    print(int(sum(H_sort)))
else:
    print(int(sum(H_sort[:-K])))

Submission status: Accepted

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


if(K >= N):
    print(0)
else:
    new_li = li[0:N-K]
    print(sum(new_li))

Submission status: Accepted

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

H.sort(reverse=True)

for i in range(min(N,K)):
    H[i]=0

print(sum(H))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a, b = map(int, input().split())
N = list(map(int, input().split()))
N.sort()
for i in range(b):
    if N:
        N.pop()
print(sum(N))

Submission status: Accepted

Solution code:
n,k = map(int,input().split())
oppo = list(input().split())
for i in range(len(oppo)):
    oppo[i] = int(oppo[i])

oppo = sorted(oppo)
attack = 0

if  k >= n:
    print(0)
else:
    for i in range(0,len(oppo)-k):
        attack = attack + oppo[i]
    print(attack)

Submission status: Accepted

Solution code:
N = 0
K = 0

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

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

H_list.sort(reverse=True)
  
#print(H_list,H_list[K:])
print(sum(H_list[K:]))

Submission status: Accepted

Solution code:
H,K = map(int,input().split())
H = list(map(int,input().split()))
H.sort()
if len(H) <= K:
  print(0)
elif K==0:
  print(sum(H))
else:
  print(sum(H[0:-K]))

Submission status: Accepted

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

    del H[0:K]
    print(sum(H))

Submission status: Accepted

Solution code:
def run():
  N, K = map(int, input().split())
  H_li = sorted(map(int, input().split()))
  if N <= K:
    print(0)
  else:
    H_sum = sum(H_li[:N-K])
    print(H_sum)
  
if __name__ == '__main__':
  run()

Submission status: Accepted

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

x=min(n,k)
del h[0:x]

#for i in range(min(n,k)):
#    h[i]=0

print(sum(h))

Submission status: Accepted

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

if K==0:
	print(sum(s))
elif K!=0:
	ans=sum(s[:-K])
	print(ans)

Submission status: Accepted

Solution code:
N,K = map(int,input().split())
H = list(map(int,input().split()))
newH = sorted(H, reverse=True)
if K <= len(H):
  print(sum(newH[K:len(H)]))
else:
  print(0)

Submission status: Accepted

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

H.sort(reverse=True)

del H[:K]
print(str(sum(H)))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, K = [int(i) for i in input().split()]
H = list(reversed(sorted([int(i) for i in input().split()])))
h = H[K:]

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

Submission status: Accepted

Solution code:
a,b=map(int,input().split())
x=list(map(int, input().split()))
if b>=len(x):
    print(0)
elif b==0:
    print(sum(x))
else:
    x.sort()
    print(sum(x[:-b]))

Submission status: Accepted

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

attack_sum = 0
monster.sort()
for i in range(N - K):
    attack_sum += monster[i]
print(attack_sum)

Submission status: Accepted

Solution code:
from operator import add
from functools import reduce

val = input().split(' ')
h = int(val[0])
k = int(val[1])
h = sorted([int(i) for i in input().split(' ')])

remains = h[:-k] if k > 0 else h
print(reduce(add, remains) if len(remains) > 0 else 0)

Submission status: Accepted

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

    n_attack = 0
    for i in range(len(h)-k):
        n_attack += h[i]

    print(n_attack)

Submission status: Accepted

Solution code:
n,k = map(int,input().split())
a = sorted(list(map(int,input().split())),reverse=True)
summ = 0
if k > 0 and k < n:
    del a[0:k]
elif n <= k:
    a = []
summ = sum(a)
print(summ)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def resolve():
    n, k = map(int, input().split())
    hp = list(map(int, input().split()))
    hp.sort()
    if n > k:
        for i in range(k):
            hp.pop()
    else:
        for i in range(n):
            hp.pop()
    print(sum(hp))




if __name__ == "__main__":
    resolve()

Submission status: Accepted

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

  print(ans)

Submission status: Accepted

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

h_2 = sorted(h, reverse=True)

if n <= k:
    print(0)

else:
    h_3 = h_2[k:]
    print(sum(h_3))

Submission status: Accepted

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

rm = sorted(H)[0:max(N-K, 0)]
print(sum(rm))

Submission status: Accepted

Solution code:

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

#print(N)
#print(K)
#print(H)

# Hをソートする
H_SORT = sorted(H, reverse=True)

#print(H_SORT)
#del H_SORT[0:K]
#print(H_SORT)
if K >=N:
    print(0)
else:
    del H_SORT[0:K]
    SUM = 0
    for j in range(len(H_SORT)):
        SUM += H_SORT[j]

    print(SUM)

Submission status: Accepted

Solution code:
import heapq
[n, k] = list(map(int, input().split()))
Healths = list(map(int, input().split()))
sum = 0
hh = heapq.nlargest(k, Healths)
for h in hh:
  sum+=h

sum2=0
for h in Healths:
  sum2+=h

print(sum2 - sum)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,K=input().split()
A=list(map(int,input().split()))
n=int(N)
k=int(K)
B=sorted(A)
ans=0
for i in range(n-k):
  ans+=B[i]
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

print(ans)

Submission status: Accepted

Solution code:
n, k = input().split()
N = int(n)
K = int(k)
lis_H= list(map(lambda x: int(x), input().split()))
haha = sorted(lis_H)
haha.reverse()
ans = sum(haha[K:])
print(ans)

Submission status: Accepted

Solution code:
import sys
import numpy as np

# N K モンスターの数と必殺技の回数
n, k = map(int, input().split())

# H1 ... モンスターの体力
h = list(map(int, input().split()))

h.sort(reverse=True)
h_ar = np.array(h)

if k > 0:
    h_ar[:k] = 0

print(h_ar.sum())

Submission status: Accepted

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

ans = sum(list[k:])

print(ans)

Submission status: Accepted

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

monsters = sorted(monsters)

left_num = N-K
if left_num <= 0:
    print(0)
else:
    left_mosnters = monsters[:left_num]
    print(sum(left_mosnters))

Submission status: Accepted

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

Submission status: Accepted

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

del H[0:K]

print(sum(int(i) for i in H))

Submission status: Accepted

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

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

H.sort(reverse = True)

answer = sum(H[K:])
print(answer)

Submission status: Accepted

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
import fractions
input = sys.stdin.readline
N, K = map(int, input().split())
H = list(map(int, input().split()))
H.sort()
if K != 0:
    H = H[:-K]
print(sum(H))

Submission status: Accepted

Solution code:

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

for _ in range(K): 
  if len(H) > 0: H.pop()
  else: break

print(sum(H))

Submission status: Accepted

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

print(c)

Submission status: Accepted

Solution code:
N, K = map(int,input().split())
H = [int(i) for i in input().split()]
H.sort()
sum = 0
if K > N:
    pass
else:
    for i in range(len(H)-K):
        sum += H[i]

print(sum)

Submission status: Accepted

Solution code:
nk = list(map(int, input().split()))
n = nk[0]
k = nk[1]
h = list(map(int, input().split()))

#hの上からkばんめまでに必殺技を撃つのが最適解のはず
h_sorted = sorted(h)
l = 0
if k > 0 and k <= n:
    l = h_sorted[-k]
elif k > n:
    l = 0
else:
    l = 10 ** 10

r = 0
for hh in h:
    if hh < l:
        r += hh

print(r)

Submission status: Accepted

Solution code:
N,K = map(int,input().split(" "))
l = list(map(int,input().split(" ")))
H = sorted(l,key=int) 
c = 0
if(K >= N):
    c = 0
else:
    for i in range(K):
        del H[-1]
    for i in H:
        c = c+i
print(c)

Submission status: Accepted

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

if K>len(H):
    print("0")
else:
    heap=[]
    for item in H:
        item=item*(-1)
        heapq.heappush(heap, item)

    for _ in range(K):
        heapq.heappop(heap)

    H2 = list(map(lambda x: x * (-1), list(heap)))
    # print(H2)
    H2 = sum(H2)
    print(H2)

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
H = sorted(map(int, input().split()))
ans = 0

if n <= k:
    print("0")
else:
    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()))

h.sort()

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

Submission status: Accepted

Solution code:
n, k = map(int, input().strip().split())
h = list(map(int, input().strip().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())
h_list = list(map(int,input().split()))
h_list.sort(reverse=True)
if k>= len(h_list):
  print(0)
elif k ==0 :
  print(sum(h_list))
else:
  del h_list[:k]
  print(sum(h_list))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
h=list(map(int,input().split()))
h.sort(reverse=True)
if(k>=len(h)):
    print(0)
else:
    i=0
    while(i!=k):
        h[i]=0
        i+=1
    print(sum(h))

Submission status: Accepted

Solution code:

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

h.sort(reverse=True)

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

Submission status: Accepted

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

Submission status: Accepted

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

H.sort(reverse=True)
J = H[K:(N+1)]
C = sum(J)

print (C)

Submission status: Accepted

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

H = sorted(H, reverse=True)
if K >= len(H):
    print(0)
else:
    del H[0:K]
    print(sum(H))

Submission status: Accepted

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


def main():
    _h = sorted(H)

    if K > 0:
        _h = _h[0:-K]

    # print(_h)
    return sum(_h)


ans = main()

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
H = list(map(int, input().split()))  # リスト入力 「a1 a2 a3 ...」みたいな配列のような入力のとき
s=0
if K>=N:
    print(0)
else:
    H.sort()
    for i in range(K):
        H[N-i-1]=0
    for i in range(N):
        s+=H[i]
    print(s)

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:n+1]) )

Submission status: Accepted

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

if k == 0:
    print(sum(H))
    exit()

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

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

Submission status: Accepted

Solution code:
# coding: utf-8
def main():
    N, K = map(int, input().split())
    H = input().split()
    H = [int(i) for i in H]

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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

if n <= a:
  print(0)
else:
  aaa = list(map(int, input().strip().split()))

  aaa = sorted(aaa, reverse=True)
  h = 0
  for i in range(a, n):
    h += aaa[i]

  print(h)

Submission status: Accepted

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

Submission status: Accepted

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

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()
ans = 0
for i in range(n-k):
  ans += h[i]
print(ans)

Submission status: Accepted

Solution code:
import math

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from sys import stdin
lines = stdin.readlines()
 
N, K = map(int, lines[0].split())
H = sorted(map(int, lines[1].split()), reverse=True)

print(sum(H[K:]))

Submission status: Accepted

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

Submission status: Accepted

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

li.sort()
li.reverse()

su=0

if n<=k:
    print('0')
else:
    print(sum(li[k:]))

Submission status: Accepted

Solution code:
N,K=map(int,input().split())
H=sorted(list(map(int,input().split())),reverse=True)
if N<K:K=N
for i in range(K):H[i]=0
print(sum(H))

Submission status: Accepted

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

h.sort()
k = min(k,n)
print(sum(h[0:n-k]))

Submission status: Accepted

Solution code:
x = input().split(" ")
n = int(x[0])
k = int(x[1])
h = list(map(int,input().split(" ")))

h.sort(reverse=True)

ans = 0
if k >= n:
    print(0)
else:
    for i in range(k,n):
        ans += h[i]
    print(ans)

Submission status: Accepted

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

H.sort()

if(N<=K):
  print(0)
else:
  for i in range(K):
    H.pop()
  print(sum(H))

Submission status: Accepted

Solution code:
def attacks(k, healths):
    if k == 0:
        return sum(healths)

    healths.sort()
    return sum(healths[:-k])


if __name__ == '__main__':
    n, k = ([int(s) for s in input().split()])
    healths = [int(s) for s in input().split()]

    print(attacks(k, healths))

Submission status: Accepted

Solution code:
tekinokazu, hissatsu = map(int, input().split())
hp_list = list(map(int, input().split()))

hp = sorted(hp_list, reverse=True)

del hp[:hissatsu]

print(sum(hp))

Submission status: Accepted

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    N,K = (int(x) for x in input().split())
    h = list(map(int, input().strip().split()))
    H = sorted(h, reverse=True)
    del H[:K]
    print(sum(H))


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
l=[int(x) for x in input().split()]
l.sort()
while k and len(l):
    l.pop()
    k-=1
if len(l):
    print(sum(l))
else:
    print(0)

Submission status: Accepted

Solution code:
N,K = map(int,input().split())
H = list(map(int,input().split()))
lst=sorted(H)
if K > len(H):
  K=len(H)
for i in range(K):
  lst[N-i-1]=0
ans=sum(lst)
print(ans)

Submission status: Accepted

Solution code:
a=input()
N,K=int(a.split()[0]),int(a.split()[1])
b=input().split()
list=list(map(int, b))

if (K>=len(list)):
  print(0)
else:
  print(sum(sorted(list, reverse=True)[K:]))

Submission status: Accepted

Solution code:
# Enter your code here. Read input from STDIN. Print output to STDOUT

import numpy as np
from sys import stdin


def get_result(data):
    N, K = data[0]
    H = sorted(data[1])
    return 0 if N <= K else sum(H[0:(N-K)])

if __name__ == '__main__':
    raw_data = [val.rstrip('\n') for val in stdin.readlines()]
    data = [list(map(int, val.split(' '))) for val in raw_data]
    result = get_result(data)
    print(result)

Submission status: Accepted

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

H.sort(reverse=True)
nokori = H[K:]
print(sum(nokori))