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:
en_num, hiss_num = [int(a) for a in input().split(' ')]
en_h_list = [int(b) for b in input().split(' ')]
en_h_list.sort()

aa = max(0, len(en_h_list)-hiss_num)

en_h_list = en_h_list[:aa]

print(
  sum(en_h_list)
)

Submission status: Accepted

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

resolve()

Submission status: Accepted

Solution code:

def main():
    n, k = map(int, input().split())
    h = list(map(int, input().split()))
    h.sort(reverse=True)
    result = 0

    for i in range(n):
        if k > 0:
            k -= 1
        else:
            result += h[i]
    print(result)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

H = list(reversed(sorted(H)))

print(sum(H[K:]))

Submission status: Accepted

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

n, k = map(int, input().split())
H = sorted([int(i) for i in input().split()], reverse=True)

if k == 0:
    print(sum(H))
elif 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()))
if n<=k:
    print(0)
else:
    t=sorted(h,reverse=1)
    t=t[:k]
    p=sum(h)-sum(t)
    print(p)

Submission status: Accepted

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

if k >= len(hp_list):
    print(0)
    sys.exit()

hp_list = hp_list[k:]
print(sum(hp_list))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
i = list(map(int,input().split()))
i2 = list(map(int,input().split()))

i2.sort(reverse=True)

if i[1] >= i[0]:
    print("0")
else:
    del i2[:-i[0]+i[1]]
    print(sum(i2))

Submission status: Accepted

Solution code:
import numpy as np
N, K = map(int, input().split())
H = np.array([int(i) for i in input().split()], dtype='u8')
if K > 0:
    print(np.sum(np.sort(H)[:-K]))
else:
    print(np.sum(H))

Submission status: Accepted

Solution code:
def LI():
  return [int(s) for s in input().split()]

N,K = LI()
H = LI()

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

H_sort = sorted(H,reverse = True)
print(sum(H_sort[K:]))

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

h_L.sort(reverse=True)
#print(h_L)
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()))
H.sort()
if K >= N:
  print(0)
else:
  print(sum(H[:N-K]))

Submission status: Accepted

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

h_sorted = sorted(h)
# kが0だった場合のルーチン
if(k == 0):
	print(sum(h_sorted))
else:
	print(sum(h_sorted[:-k]))

Submission status: Accepted

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

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

sortedmylist=sorted(mylist, reverse=True)
#print(sortedmylist)


if N<=K:
    print(0)
    
else:
    del sortedmylist[:K]
    #print(sortedmylist)
    print(sum(sortedmylist))

Submission status: Accepted

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

h_list.sort(reverse=True)
attack_num = 0
for i in range(len(h_list) - k):
    attack_num += h_list[k + i]

print(attack_num)

Submission status: Accepted

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

h = sorted(h, reverse=True)
ans = 0
if k >= n:
    print(ans)
else:
    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()))
h_s=sorted(h,reverse=True)
ans=print(sum(h_s[k:]))

Submission status: Accepted

Solution code:
import bisect

n, k = map(int, input().split())
l = sorted(map(int, input().split()))

c = len(l) - k
if c < 0:
    c = 0
    
print(sum(l[:c]))

Submission status: Accepted

Solution code:
import sys
import math
from collections import deque
input = sys.stdin.readline
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:
b,k=map(int,input().split())
h=list(map(int,input().split()))
h=sorted(h)
if k==0:
    print(sum(h))
else:
    print(sum(h)-sum(h[-k:]))

Submission status: Accepted

Solution code:
n,k = map(int, input().split()  ) #split()で分解したものを別々の変数に入れる
h = list(map(int, input().split()))
h.sort()
result = 0
for i in range(n - k):
    result += h[i]

print(result)

Submission status: Accepted

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

Submission status: Accepted

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

del H[:K]

if len(H) == 0:
    print(0)
else:
    print(sum(H))

Submission status: Accepted

Solution code:
N, K = list(map(int, input().split()))  # N:敵の数，K:必殺技の数
H_list = list(map(int, input().split()))

count = sum(sorted(H_list, reverse=True)[K:])

print(count)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import heapq
N,K=map(int,input().split())
H=list(map(lambda x: int(x)*(-1), input().split()))
heapq.heapify(H)
ans=0
if K>=N:
    ans=0
else:
    for i in range(K):
        a=heapq.heappop(H)
    ans=-1*sum(H)
print(ans)

Submission status: Accepted

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

def main():
    N, K = input().split()
    N = int(N)
    K = int(K)
    monster = list(map(int, input().split()))
    monster = sorted(monster, reverse=True)
    print(sum(monster[K:]))


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)

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

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

Submission status: Accepted

Solution code:
import sys
import numpy as np

input = sys.stdin.readline

N, K = list(map(int, input().split()))
H = np.sort(np.array(list(map(int, input().split()))))[::-1]

if N <= K:
    print(0)
    sys.exit()

print(np.sum(H[K:]))

Submission status: Accepted

Solution code:
a, b = map(int, input().split())
array = list(map(int, input().strip().split()))
array_sort = sorted(array)
out = 0 if a <= b else sum(array_sort[0:a-b])
print(out)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

H , A = map(int, input().split())
li = list(map(int,input().split()))

if H <= A:
    print(0)
    sys.exit()

sli = sorted(li, reverse=True)

print(sum(li) - sum(sli[:A]))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# N体のモンスター, K回まで必殺技が使える
N, K = map(int, input().split())

# モンスターの体力 高い順
H_list = list(map(int, input().split()))
H_list = sorted(H_list, reverse=True)

# K番目のモンスターまでは必殺技で殺す
H_list = H_list[K:]

# 残りのモンスターのHP数を合計する
HP_sum = sum(H_list)

print(HP_sum)

Submission status: Accepted

Solution code:
def  fenec(N,K,H):
    H.sort()
    try :
        for i in range (K):
            H.pop()
    except:
        return 0
    rest_hp  = sum(H)
    
    return rest_hp        
8 


inp = input().split()
inp_ = input().split()
N = int(inp[0])
K = int(inp[1] )
H= [int(i) for i in inp_]

print(fenec(N,K,H))

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
Hs = list(map(int, input().split()))
Hs.sort()
for _ in range(K):
  if len(Hs)==0:
    break
  Hs.pop(-1)
print(sum(Hs))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
his = list(map(int, input().split()))
his_sort = sorted(his)
an = 0
if k > 0:
  for i in range(k):
    his_sort.pop()
    if len(his_sort) == 0:
      break
if len(his_sort) > 0:
  for j in range(n - k):
    an += his_sort[j]
print(an)

Submission status: Accepted

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

if len(H) <= K:
    print(0)
    exit()

sort_H = sorted(H)
for i in range(K):
    sort_H.pop(-1)

sm = sum(sort_H)

print(sm)

Submission status: Accepted

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

Submission status: Accepted

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

H = sorted(H)
if k >= n:
  print(0)
  sys.exit()

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

if k >= n:
  print(0)

elif k==0:
  print(sum(h))

else:
  h.sort()
  del h[-k:]
  print(sum(h))

Submission status: Accepted

Solution code:
n, k, *h = map(int, open(0).read().split())

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

h.sort(reverse=True)


sum = 0
for i in range(k, n):
  sum += h[i]

print(sum)

Submission status: Accepted

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

H.sort()

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

Submission status: Accepted

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

Submission status: Accepted

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


def solve(N: int, K: int, H: "List[int]"):
    H.sort()
    if K>=len(H):
        print(0)
    else:
        for i in range(K):
            del H[-1]
        print(sum(H))
    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
    K = int(next(tokens))  # type: int
    H = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, K, H)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

h = sorted(h)

print(sum(h[:max(0, n-k)]))

Submission status: Accepted

Solution code:
import sys
import itertools
read = sys.stdin.buffer.read #全てまとめて文字列として格納
readline = sys.stdin.buffer.readline # 一行読む
readlines = sys.stdin.buffer.readlines # 全行リストに格納
N,K = map(int, readline().split())
H = list(map(int, readline().split()))
N -= K
if N <= 0 :
  print(0)
  exit()

H.sort()

count=0
for i in range(N):
  count+=H[i]
print(count)
exit()

Submission status: Accepted

Solution code:
t = []
t = list(map(int, input().split()))

k = t.pop()
n = t.pop()

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

h.sort()

for i in range(k):
    if len(h)>0:
        h.pop()

total = sum(h)
print(total)

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

Submission status: Accepted

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

if k >= len(a):
    print(0)
else:
    res = a[k:]
    print(sum(res))

Submission status: Accepted

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

input2 = input().split()
Monster_list = list(map(int,input2))


Monster_list.sort(reverse=True)


del Monster_list[0:K]


print(sum(Monster_list))

Submission status: Accepted

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

Submission status: Accepted

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

ls = sorted(ls)


if len(ls)<k+1:
  print(0)
else:
  print(sum(ls[:-k]) if k>0 else sum(ls))

Submission status: Accepted

Solution code:

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

n2 = sorted(n, reverse=True)
ans = sum(n2[k:])

print(ans)

Submission status: Accepted

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

H.sort()

count = N - K

ans = 0
for i in range(count):
    ans = ans + H[i]



print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import heapq
n,k=map(int,input().split())
a=[int(x) for x in input().split()]
if k>n:
    print(0)
else:
    f=heapq.nsmallest(n-k,a)
    print(sum(f))

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:
#C
import heapq

N, K = map(int, input().split())
H = list(map(int, input().split()))
H = list(map(lambda x: x*(-1), H))
heapq.heapify(H)

if K >= N:
    print(0)
else:
    for _ in range(K):
        heapq.heappop(H)
    print(-sum(H))

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
listh = list(map(int, input().split()))
list.sort(listh, reverse=True)
#print(listh)
if N <= K:
    print(0)
    exit
else:
    del listh[:K]
    #print(listh)
    ans = sum(listh)
    print(ans)

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.sort()
    print(sum(h[:-k]))

Submission status: Accepted

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

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

Submission status: Accepted

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

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)
hits = 0
for x in H:
    if K != 0:
        K -= 1
        continue
    else:
        hits += x
print(hits)

Submission status: Accepted

Solution code:
import heapq
n,k=list(map(int,input().split()))
h=list(map(lambda x:int(x)*(-1),input().split()))
heapq.heapify(h)
if k>len(h):k=len(h)
for i in range(k):
  heapq.heappop(h)
print(-sum(h))

Submission status: Accepted

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

Submission status: Accepted

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

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 = [int(i) for i in input().split()]
h.sort(reverse=True)
if k >= n:
    print(0)
else:
    del h[:k]
    print(sum(h))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, MP = map(int, input().split())
lists = list(map(int, input().split()))
if len(lists) <= MP:
    print(0)
else:
    lists.sort()
    for i in range(0,MP):
        del lists[-1]
    ans = sum(lists)
    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:
A = list(map(int , input().split()))
B = list(map(int , input().split()))
if A[0] < A[1]:
    print(0)
else:
    B.sort(reverse=True)
    del B[0:A[1]]
    print(sum(B))

Submission status: Accepted

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


def solve(N: int, K: int, H: "List[int]"):
    H = sorted(H, reverse=True)
    H = H[K:]
    result = sum(H)
    print(result)
    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
    K = int(next(tokens))  # type: int
    H = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, K, H)


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)<=0:
  print(0)
else:
  print(sum(h[:(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)
else:
    h = sorted(h, reverse=True)
    print(sum(h[k:]))

Submission status: Accepted

Solution code:
# coding:UTF-8

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

count = 0

health = sorted(health,reverse=True)

print(sum(health[K:]))

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:]))

Submission status: Accepted

Solution code:
import sys
import math

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

li.sort(reverse=True)

atk = 0

for i in range(len(li)):
    if i>=k:
        atk += li[i]
        
print(atk)

Submission status: Accepted

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

nums.sort()
if k != 0:
    ans = sum(nums[:-k])
else:
    ans = sum(nums)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

import math

# H,N=3,1
# l=[4,1,5]

import sys
if N>=len(l):
    print(0)
    sys.exit()

    
sort_l=sorted(l)
delete_l=sort_l[:len(l)-N]
print(sum(delete_l))

Submission status: Accepted

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

sorted_h = sorted(h)

num = 0
if k >= len(sorted_h):
    print('0')
elif k == 0:
    print(sum(sorted_h))
else:
    del sorted_h[-k:]
    print(sum(sorted_h))

Submission status: Accepted

Solution code:
#C
#入力
N,K=map(int,input().split())
H=list(map(int,input().split()))
#処理
H.sort()
x=0
for i in range(len(H)-K):
    x+=H[i]
print(x)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,K = map(int,input().split())
H = list(map(int,input().split()))
H.sort()
ans = 0
if N <= K:
  print(0)
  exit()
for i in range(0,N-K):
  ans += H[i]
print(ans)

Submission status: Accepted

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


if k>=n:
    print(0)
    
else:
    mon3=mon2[:n-k]
    print(sum(mon3))

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
import heapq

ans=0
n,k=map(int,input().split())
enemy=list(map(int,input().split()))
if k>=len(enemy):
    print(0)
else:
    for  i in range(len(enemy)):
        enemy[i]*=(-1)
    heapq.heapify(enemy)

    for i in range(k):
        heapq.heappop(enemy)


    while len(enemy)>0:
        ans += heapq.heappop(enemy)*(-1)

    print(ans)

Submission status: Accepted

Solution code:
#abc153 a
#153 c
n,k=map(int,input().split())
h=list(map(int,input().split()))
ans=0
h.sort()
if k>=n:
    ans=0
else:
    for i in range(k):
        h.pop()
    ans=sum(h)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
n,k=map(int, input().split())
h=list(map(int, input().split()))
b =sorted(h)
if k != 0:
    b = b[:-k]
#攻撃回数
print(sum(b))

Submission status: Accepted

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

sort_h_list = sorted(h_list, reverse=True)
sort_h_list_length = len(sort_h_list)

print(sum(sort_h_list[K:]))

Submission status: Accepted

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

Submission status: Accepted

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

print(sum(sort[k:n]))

Submission status: Accepted

Solution code:
N, K=map(int, input().split())  #「A B」みたいなスペース空いた入力のとき

# N体分
enemy = list(map(int,input().split()))

enemy.sort()

if N <= K:
    print("0")
    # exit()
else:
    if K == 0:
        ans = sum(enemy[:])
    else:
        ans = sum(enemy[:-K])
    print(ans)

Submission status: Accepted

Solution code:
import numpy as np

N, K = map(int, input().split())
H = np.array([int(h) for h in input().split()])

H = np.sort(H)[::-1]
res = np.sum(H[K:])
print(res)

Submission status: Accepted

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

if K >= len(H):
  print(0)
  exit()

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

Submission status: Accepted

Solution code:
# your code goes here
n,k=map(int,input().split())
a=[int(i) for i in input().split()]
a.sort(reverse=True)
x=[]
if(k>=n):
	print(0)
else:
	for i in range(k):
		x.append(a[i])
	print(abs(sum(a)-sum(x)))

Submission status: Accepted

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

Submission status: Accepted

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

hd = sorted(h, reverse=True)
tmp = 0

if n < k:
    print(0)
else:
    for i in range(k): 
        tmp = tmp + hd[i]

    result = sum(h) - tmp
    print(result)

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:
    h1 = h[k:n]
    print(sum(h1))

Submission status: Accepted

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

H = list(map(int, input().split()))
H.sort()
# 必殺技
for i in range(K):
    #print(H)
    if len(H):
        H.pop()
    
print(sum(H))

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

list = list(map(int,list(input().split())))
ld = sorted(list, reverse=True)
print(sum(ld[K:]))

Submission status: Accepted

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

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

Submission status: Accepted

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

H = [int(n) for n in input().split()]

if K >= N:
    a = 0
else:
    a = sum(sorted(H)[:N-K])

print(a)

Submission status: Accepted

Solution code:
def main(n, k, h):

    h.sort()

    for i in range(k):
        try:
            h.pop()
        except IndexError:
            pass

    print(sum(h))


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

    main(n, k, h)

Submission status: Accepted

Solution code:
from functools import reduce
from operator import add

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

sortedHList = sorted(hList, reverse=True)
restHList = sortedHList[k:]
if len(restHList) == 0:
  print(0)
else:
  print(reduce(add, restHList))

Submission status: Accepted

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

Submission status: Accepted

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

li.sort()

for i in range(N-K):
    h=li[i]+h

print(h)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N, K = map(int, input().split())          
H = [i for i in map(int, input().split())]
                                          
H.sort(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()
count = sum(H[:max(N - K, 0)])
print(count)

Submission status: Accepted

Solution code:
N,K = map(int,input().split())
H = list(map(int,input().split()))
H.sort()
H.reverse()
ans = 0
for i in range(K,N):
    ans += H[i]
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

sorted_Hs = sorted(Hs, reverse=True)

del sorted_Hs[0:k]

print(sum(sorted_Hs))

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)
    exit (0)
h_list.sort(reverse=True)
del h_list[0:k]
print (sum(h_list))

Submission status: Accepted

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

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

H.sort()
if K !=0:
    c = K if N>K else 0
    H = H[0:-c]
else:
    c =-1

ans = sum(H) if c!=0 else 0


print(ans)

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