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= map(int,input().split())
h = list(map(int,input().split()))
h.sort()

if k >= n:
    print(0)
    exit()
else:
    for i in range(k):
        h.pop()

print(sum(h))

Submission status: Accepted

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

print(sum(H[K:]))

Submission status: Accepted

Solution code:
N, K = map(int, input().split(' '))
H = sorted(map(int, input().split(' ')))
if(K >= N):
    print(0)
    exit(0)
for j in range(K):
    H[N - j - 1] = 0
print(sum(H))

Submission status: Accepted

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

Submission status: Accepted

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

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

hl.sort()
e = n-k
if e <= 0:
    print(0)
    exit()
s = sum(hl[:e])
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) - sum(h[:k]))

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
N, K = map(int, input().split())
H = sorted(list(map(int, input().split())), reverse=True)
if K != 0:
    if len(H) <= K:
        print(0)
    else:
        print(sum(H[K:]))
else:
    print(sum(H))

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
N, K = map(int, input().split())
H = sorted(list(map(int, input().split())), reverse=True)
if K != 0:
    if len(H) <= K:
        print(0)
    else:
        print(sum(H[K:]))
else:
    print(sum(H))

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
N, K = map(int, input().split())
H = sorted(list(map(int, input().split())), reverse=True)
l = len(H)
if K != 0:
    if len(H) <= K:
        print(0)
    else:
        print(sum(H[K:]))
else:
    print(sum(H))

Submission status: Accepted

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

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

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())
h = list(map(int, input().split()))
# h = [i for i in range(n)]
h = sorted(h)
# print(h[:-1], h)
if k > len(h):
    print(0)
else:
    if k != 0:
        del h[-k:]
    print(sum(h))

Submission status: Accepted

Solution code:
H,k=map(int,input().split())
h=list(map(int,input().split()))
h.sort(reverse=True)
for i in range(min(H,k)):
    h[i]=0
print(sum(h))

Submission status: Accepted

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

if n <= k:
    print(0)
else:
    hh = sorted(h,reverse=True)
    del hh[0:k]
    print(sum(hh))

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:
from decimal import Decimal
n, k = map(int, input().split())
h = sorted(list(map(int, input().split())))
d = max(0,n-k)
print(sum(h[:d]))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
import heapq
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n, k = na()
h = na()
for i in range(n):
    h[i] *= -1
heapq.heapify(h)
for i in range(min(len(h), k)):
    heapq.heappop(h)
print(-1 * sum(h))

Submission status: Accepted

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

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

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

# ソートする
hp_list.sort()

# 必殺技の回数ぶん除去
for i in range(k):
    hp_list.pop()

sum_hp = 0
for hp in hp_list:
    sum_hp += hp

print(sum_hp)

Submission status: Accepted

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

list = sorted(listh,reverse = True)
list1 = list[:k]

print(sum(listh)-sum(list1))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

h=sorted(list(map(int,input().split())))
for _ in range(k):
    h.pop()
print(sum(h))

Submission status: Accepted

Solution code:
# import bisect
# import copy
# import fractions
# import math
# import numpy as np
# from collections import Counter, deque
# from itertools import accumulate,permutations, combinations,combinations_with_replacement,product

def resolve():
    N,K=map(int,input().split())
    H=sorted(list(map(int,input().split())),reverse=True)

    if K>=N:
        print(0)
    else:
        cnt=0


        H=H[K:]

        cnt+=sum(H)

        print(cnt)


resolve()

Submission status: Accepted

Solution code:

def main():
    
    h,k = map(int, input().split())

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

    h_list.sort(reverse=True)
    ans = 0
    for i in range(len(h_list)):
        if k > 0:
            k -= 1
        else:
            ans += h_list[i]

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10000000)
INF = 1<<32


def solve(N: int, K: int, H: "List[int]"):
    H.sort(reverse=True)
    print(sum(H[K:]))
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    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()
print(sum(h[:max(0, len(h) - k)]))

Submission status: Accepted

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

Submission status: Accepted

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

print(q)

Submission status: Accepted

Solution code:
# import math
# import bisect
# import heapq
# from collections import deque
# import numpy as np

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

# n = int(input())
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())
a = list(map(int,input().split()))
if n <= k:
  print(0)
else:
  a.sort()
  print(sum(a[:n-k]))

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:
n, k = map(int, input().split())
mon = list(map(int, input().split()))
mon.sort()
if k == 0:
    print(sum(mon))
else:
    print(sum(mon[:-k]))

Submission status: Accepted

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

print(sum(sorted(h, reverse=True)[k:]))

Submission status: Accepted

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

hlist.sort(reverse=True)

if n<k:
    k = n
for i in range(0,k):
    hlist[i] = 0

print(sum(hlist))

Submission status: Accepted

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

K = min(N, K)
ans = sum(H[:N-K])
print(ans)

Submission status: Accepted

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

print(sum(H))

Submission status: Accepted

Solution code:
list = input().split(" ")
N = int(list[0])
K = int(list[1])
list_hp = input().split(" ")
list_hp = [int(i) for i in list_hp]
list_hp = sorted(list_hp)

if K < N:
    sum = 0
    for i in range(N-K):
        sum = sum + list_hp[i]
    print(sum)
else:
    print(0)

Submission status: Accepted

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

Submission status: Accepted

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

enamy1 = sorted(enamy, reverse=True)
if len(enamy) <= k:
  print(0)
else:
  del enamy1[0:k]
  print(sum(enamy1))

Submission status: Accepted

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

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

Submission status: Accepted

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

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

H.sort()

sum = 0

for i in range(N-K):
    sum = sum+int(H[i])
    
print(sum)

Submission status: Accepted

Solution code:
from collections import deque 
num, K = map(int, input().split())
monster = list(map(int, input().split()))
monster.sort(reverse=True)
ans = deque(monster)
for i in range(K):
  if len(ans)==0:
    print(0)
    exit()
  ans.popleft()
  
print(sum(ans))

Submission status: Accepted

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

for i in range(K):
  del li[-1]
  if len(li) < 1:
    print(0)
    exit()

print(sum(li))

Submission status: Accepted

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

Submission status: Accepted

Solution code:


def submit():
    n, k = map(int, input().split())
    hlist = list(map(int, input().split()))

    if k >= n:
        print(0)
        return

    if k == 0:
        print(sum(hlist))
        return

    hlist.sort()
    print(sum(hlist[:-k]))


if __name__ == "__main__":
    submit()

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:
H,N = map(int,input().split())
A = list(map(int,input().split()))
A.sort(reverse = True)
cnt = 0

if H <= N:
    A.clear()
else:
    for i in range(N):
        A[cnt]= 0
        cnt += 1
        
print(sum(A))

Submission status: Accepted

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

def solve():
    N, K = list(map(int, input().split()))
    Hs = list(map(int, input().split()))

    Hs.sort(reverse=True)

    ans = 0
    for h in Hs:
        if K > 0:
            K -= 1
            continue
        ans += h
    print(ans)


if __name__ == "__main__":
    solve()

Submission status: Accepted

Solution code:
import numpy as np
from collections import Counter

# 最頻値
def mode(list):
    c = Counter(list)
    freq_scores = c.most_common()
    max_count = freq_scores[0][1]
    modes = []
    for num in freq_scores:
        if num[1] == max_count:
            modes.append(num[0])
    return(modes)

n, k = map(int, input().split())
h_list = list(map(int, input().split()))
h_list.sort()
h_list.reverse()
del h_list[0:k]
print(sum(h_list))

Submission status: Accepted

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

if k>n:
  k=n
  
for i in range (k):
  l[i]=0

c+=sum(l)

print(c)

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())
monsters = list(map(int, input().split()))
monsters.sort(reverse=True)

monsters = monsters[K:]
print(sum(monsters))

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
h = list(map(int, input().split()))
h.sort()
use_sp = min(k, len(h))
for _ in range(use_sp): h.pop()
print(sum(h))

Submission status: Accepted

Solution code:
from math import ceil

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:
from sys import stdin
import math

n, k = [int(x) for x in stdin.readline().rstrip().split()]
h = [int(x) for x in stdin.readline().rstrip().split()]

list.sort(h, reverse=True)

cnt = 0
for i in h:
    if k > 0:
        k -= 1
        continue
    cnt += i

print(cnt)

Submission status: Accepted

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

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 = 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:
n,k = map(int, input().split())
a = sorted(list(map(int, input().split())))
res = 0
if k >= n:
  print(0)
else:
  a = a[:n-k]
  for i in a:
    res += i
  print(res)

Submission status: Accepted

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

def main():
    N, K = map(int, input().split())
    H = sorted(list(map(int, input().split())))

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




if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

if n<=k:
    print(0)
else:
    l.sort(reverse=True)
    print(sum(l[k:n]))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys 

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

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

q_lis = H[0:len(H)-K]

print(sum(q_lis))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def solve():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    A.sort(reverse=True)
    ans = 0
    for i, a in enumerate(A):
        if i < K: continue
        ans += a
    return ans

print(solve())

Submission status: Accepted

Solution code:
def solve():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    A.sort()
    A = reversed(A)
    ans = 0
    for i, a in enumerate(A):
        if i < K: continue
        ans += a
    return ans

print(solve())

Submission status: Accepted

Solution code:
def solve():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    A.sort()
    if K >= N:
        return 0
    if K == 0:
        return sum(A)
    l = A[:-K]
    return sum(l)

print(solve())

Submission status: Accepted

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

b.sort()
x=a[1]
y=a[0]
if x>=y:
	print(0)
else:
	z=y-x
	b=b[0:z]
	print(sum(b))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

monsters.sort(reverse=True)
for i in range(K) :
    if (i < len(monsters)) :
        monsters[i] = 0

print(sum(monsters))

Submission status: Accepted

Solution code:
N,K=(int(x) for x in input().split())
a=list(int(y) for y in input().split())
b=sorted(a)
if N<=K:
    print('0')
else:
    print(sum(b[0:N-K]))

Submission status: Accepted

Solution code:
N,K=(int(x) for x in input().split())
a=list(int(y) for y in input().split())
b=sorted(a)
if K<N:
    print(sum(b[0:N-K]))
else:
    print(0)

Submission status: Accepted

Solution code:
nk = [int(s) for s in input().split()]
n = nk[0]
k = nk[1]

hp = [int(s) for s in input().split()]

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

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

    if k==0:
        print(sum(i))
        exit()
    else:
        j = i[k:]
        print(sum(j))
resolve()

Submission status: Accepted

Solution code:
#ABC153

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

l = h[:n-k]
# print(h,l,sum(l))

if n <= k:
    print(0)
else:
    print(sum(l))

Submission status: Accepted

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

hps = sorted(hps,reverse=True)
hps = hps[k:]
hpsum = int(sum(hps))

print(hpsum)

Submission status: Accepted

Solution code:
def solve():
    _, k = map(int, input().split())
    h = map(int, input().split())
    h = list(reversed(sorted(h)))

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

    print(sum(h))
if __name__ == "__main__":
    solve()

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
#print("n={}, k={}".format(n,k))

A = list(map(int, input().split()))
#print(h)

A.sort(reverse=True)
#print(hs)

print(sum(A[k:]))

Submission status: Accepted

Solution code:
from collections import deque

# ans = True
# print(["Yes", "No"][ans])

h, k, *a = map(int, open(0).read().split())
k = min(h,k)

a.sort()
for _ in range(k):
    a.pop()

print(sum(a))

Submission status: Accepted

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

if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
from sys import stdin

N,K = [int(x) for x in stdin.readline().rstrip().split()]
H = list(map(int,input().split()))
H.sort()
if K==0:
  print(sum(H))
else :
  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:
    for i in range(k):
        H.pop(n-i-1)
    ans=sum(H)
else:
    ans=0
print(ans)

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 = list(map(int, input().split()))
if N<=K:
    print(0)
else:
    ans = 0
    H = sorted(H)
    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 = sorted(h, reverse = True)

s = 0
t = 0
for i in h:
  if t < k:
    t += 1
    continue
  s += i
print(s)

Submission status: Accepted

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

H = list(map(int, input().split()))
H.sort(reverse=True)
hit_count = 0
for i in range(K, len(H)):
    hit_count = hit_count + H[i]

print(hit_count)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Hlist=list(map(int,input().split()))
Hlist.sort()

if k >= n:
	print(0)
else:
	Hsum=0
	for i in range(n-k):
		Hsum += Hlist[i]
	print(Hsum)

Submission status: Accepted

Solution code:
#coding:utf-8
import sys,os
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = (lambda *something: print(*something)) if 'TERM_PROGRAM' in os.environ else lambda *x: 0
def main(given=sys.stdin.readline):
    input = lambda: given().rstrip()
    LMIIS = lambda: list(map(int,input().split()))
    II = lambda: int(input())
    XLMIIS = lambda x: [LMIIS() for _ in range(x)]
    YN = lambda c : print('Yes') if c else print('No')
    MOD = 10**9+7

    N,K = LMIIS()
    H = LMIIS()
    if N <= K :
        print(0)
        return
    H.sort(reverse=True)
    print(sum(H[K:]))
    return

    

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

ans = 0

if N <= K:
    pass
else:
    for i in range(N - K):
        ans += H[i]

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,K = map(int,input().split())
mons = list(int(i) for i in input().split())
mons.sort(reverse= True)

if N>K:
    for x in range(K):
        mons[x] = 0
    atSum = sum(mons)
    print(atSum)
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[0:n-k]))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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


h = sorted(h,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=sorted(h,reverse=True)
if n>=k:
 for i in range(k):
  H[i]=0
 print(sum(H))
else: 
 print(0)

Submission status: Accepted

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

Submission status: Accepted

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

h.sort(reverse = True)

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# ABC 153C
import numpy as np
n, k = map(int, input().split())
h = list(map(int, input().split()))
h = np.array(h)
h = np.sort(h)
if k >= n:
    print(0)
else:
    if k>0:
        print(np.sum(h[:-k]))
    else:
        print(np.sum(h))

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:
    if k==0:
        a=h
    else:
        a=h[:-k]
    summ=0
    for i in a:
        summ+=i
    print(summ)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def fennec(n, k):
    if n <= k:
        print("0")
    else:
        hp_list = list(map(int, input().split()))
        hp_list.sort()
        attack = 0
        for i in range(int(n) - int(k)):
            attack += hp_list[i]
        print(attack)
        
        
n, k = map(int, input().split())
fennec(n, k)

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
h = list(map(int, input().split()))
h.sort(reverse=True)
count = 0
for i in h:
    if k != 0:
        k -= 1

    else:
        count += i
print(count)

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

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

Submission status: Accepted

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

H.sort(reverse = True)

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

print(ans)

Submission status: Accepted

Solution code:
import heapq

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

minus_H = [i * (-1) for i in H]
heapq.heapify(minus_H)

for i in range(min(N, K)):
    heapq.heappop(minus_H)

ans = - sum(minus_H)

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

c.sort(reverse=True)
cntAtk = 0
for i in range(a - b):
    cntAtk = cntAtk + c[i + b]

print(cntAtk)

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 = list(map(int, input().split()))
H = sorted(H, reverse=True)
H_sum = 0
if len(H) <= K:
  print(H_sum)
else:
  H = H[K:]
  for i in range(len(H)):
    H_sum += H[i]
  print(H_sum)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Wed Mar  4 17:43:32 2020

@author: Kanaru Sato
"""

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 = 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)
ans=0
ans+=sum(h[k:])
print(ans)

Submission status: Accepted

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

H.sort()
H = H[::-1]
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()
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.sort()
if k != 0:
    print(sum(h[:-k]))
else:
    print(sum(h))

Submission status: Accepted

Solution code:
import sys

N,K = list(map(lambda x: int(x), input().split()))
monsters=list(map(lambda x: int(x), input().split()))

# ソート
monsters.sort(reverse=True)

# これでもN > Kの時の場合分けいるか
if N <= K:
  print(0)
  sys.exit()

# Kの数だけ削除
monsters = monsters[K:N]

# 配列の合計値を出力
print(sum(monsters))