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

if k>n:
    k=n
del l[:k]

print(sum(l))

Submission status: Accepted

Solution code:
import sys

n, k, *h = map(int, sys.stdin.read().split())

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

if __name__ ==  '__main__':
    main()

Submission status: Accepted

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

h = sorted(h)

h.reverse()

print(sum(h[k:]))

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
h=sorted(list(map(int,input().split())),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())
H = list(map(int,input().split()))
H.sort()
ans = sum(H[0:max(0,N-K)])
print(ans)

Submission status: Accepted

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

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

new_arr= sorted(arr, reverse=True)

for i in range(K):
    new_arr[i] = 0

print(sum(new_arr))

Submission status: Accepted

Solution code:
n,s = map(int, input().split())
l = list(map(int, input().split()))
l.sort()
i = 1
while(s>0 and l[0]>0):
    l[-i] = 0
    s-=1
    i+=1
print(sum(l))

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

print(sum(sorted(H)[::-1][K:]))

Submission status: Accepted

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

monster = H[0:N-K]

if K >= N:
    print(0)
else:
    print(sum(monster))

Submission status: Accepted

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

if len(H)<=K:
    ans = 0
else:
    Dmg = sum(H[K:])
    ans = Dmg
print(ans)

Submission status: Accepted

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

H.sort(reverse=False)

for i in range(K):
    if len(H)==0:
        break
    H.pop(-1)

print(sum(H))

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
h=map(int,input().split())
h=sorted(h)
if n<=k:
  print('0')
  exit()
  
for i in range(k):
  h[-i-1]=0
print(sum(h))

Submission status: Accepted

Solution code:
#C

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

if k >= n:
    print(0)
else:
    new_h = sorted(h)
    weak = list(new_h[:n-k])
    print(sum(weak))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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:
import numpy as np
N,K = map(int,input().split())
H = np.array(list(input().split()),np.int64)
H = np.sort(H)
if K > N:
    K = N
H[N-K:N] = 0
ans = np.sum(H)
print(ans)

Submission status: Accepted

Solution code:
from math import floor,ceil,sqrt,factorial,log
from collections import Counter, deque
from functools import reduce
import numpy as np
def S(): return input()
def I(): return int(input())
def MS(): return map(str,input().split())
def MI(): return map(int,input().split())
def FLI(): return [int(i) for i in input().split()]
def LS(): return list(MS())
def LI(): return list(MI())
def LLS(): return [list(map(str, l.split() )) for l in input()]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def LLSN(n: int): return [LS() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]

n, k = MI()

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

Submission status: Accepted

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

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

Submission status: Accepted

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

s = 0

h.sort()

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

print(s)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

print(sum(h[k:len(h)]))

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 H:
    if K >= 1:
        K -= 1
        continue
    else:
        ans += i

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

H.sort()
H.reverse()
count=0
if K<len(H):
    for i in range(K, len(H)):
        count+=H[i]
print(count)

Submission status: Accepted

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

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

ans=0
if K<N:
    for i in H[:N-K]:
        ans += i
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,K=map(int,input().split())
H=[int(i) for i in input().split()]
H.append(0)
H.sort()
if K>N:
  print(0)
else:
  for _ in range(K):
    H.pop()
  print(sum(H))

Submission status: Accepted

Solution code:

import sys
# 再起回数上限変更
# sys.setrecursionlimit(1000000)

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

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


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

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

Submission status: Accepted

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

if n - k <= 0:
    print(0)
else:
    for i in range(n-k):
        x += h[i]
    print(x)

Submission status: Accepted

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

x = 0

if n - k <= 0:
    print(0)
else:
    for i in range(n-k):
        x += h[i]
    print(x)

Submission status: Accepted

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

H, K = MAP()
H = LIST()

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()))
if n <= k:
    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()]
ans = 0
h.sort()
print(sum(h[:max(0, n-k)]))

Submission status: Accepted

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

Submission status: Accepted

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

if n <= k:
    print("0")
else:
    h_sorted = sorted(h, reverse=True)
    for i in range(k, n):
        ans += h_sorted[i]

    print(ans)

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

if k>=n:
  print(0)
  
elif k!=0:
  for i in range(k):
    h[i]=0
  print(sum(h))

else:
  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)
    exit()
if K == 0:
    print(sum(H))
    exit()


# 大きいやつからK体を0にして，残りは和
H = sorted(H)
total = sum(H)
kill = sum(H[-K:])
print(total - kill)

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n,k=map(int,input().split())
    H=[int(_) for _ in input().split()]
    H.sort(reverse=True)
    print(sum(H[k:]))

if __name__=='__main__':
    main()

Submission status: Accepted

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

def solve(N: int, K: int, H: "List[int]"):
    h = np.array(sorted(H))
    k = K if N>=K else N
    if k!=0:
        print(h[:-k].sum())
    else:
        print(h.sum())

    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:
k = min(map(int,input().split()))
H = sorted(list(map(int,input().split())))
print([sum(H),sum(H[:-k])][k != 0])

Submission status: Accepted

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

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

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()))
newh=sorted(h)

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

print(str(sum))

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
import os
import math

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

MOD = 10 ** 9 + 7


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N, K = il()
    H = il()
    H.sort(reverse=True)
    print(sum(H)-sum(H[0:K]))


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
# ABC153B
def f(n, k, h):
    if n <= k:
        print(0)
    else:
        h = sorted(h)[::-1]
        for i in range(k):
            h[i] = 0
        print(sum(h))

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

Submission status: Accepted

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

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

print(count)

Submission status: Accepted

Solution code:
import heapq
ceruleans, skills = map(int, input().split())
HP = list(map(lambda x: int(x) * (-1), input().split())) # OK! 次に進もうぜ
heapq.heapify(HP)

for i in range(skills):
  heapq.heappop(HP)

  if HP == []:
    break

print(-sum(HP))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
mons = sorted(map(int, input().split()))
print(sum(mons[: max(0, N - K)]))

Submission status: Accepted

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

Submission status: Accepted

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

N = b[0]
K = b[1]

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

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

H.sort(reverse = True)

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

sum_attack = sum(H)
print(sum_attack)

Submission status: Accepted

Solution code:
"""
int(input())
map(int,input().split())
list(map(int,input().split()))

"""

n,k=map(int,input().split())
A=list(map(int,input().split()))
A.sort()
s=0
for i in range(n-k):
    s+=A[i]

print(s)

Submission status: Accepted

Solution code:
a,b=map(int,input().split())
List=sorted(list(map(int,input().split())))
for i in range(min(b,a)):
    List.pop()
print(sum(List))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

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

Submission status: Accepted

Solution code:
# coding: utf-8
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, K = lr()
H = lr()
H.sort(reverse=True)
H = H[K:]
answer = sum(H)
print(answer)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
p,q= input().split()
a,b =(int(p), int(q))
h = map(int, input().split())
h_list = list(h)
h_list.sort()
ans_list =[]
if a<=b:
    print(0)
else:
    for i in range(a-b):
        
        ans_list.append(h_list[i])
    print(sum(ans_list))

Submission status: Accepted

Solution code:
n , k = map(int, input().strip().split())
h = input().split()
list = []
list1 = []
count = 0
for i in h:
    b = int(i)
    list.append(b)
if k>=len(list):
    print('0')
else:
    list.sort()
    for j in range(0, len(list)-k):
        list1.append(list[j])
    sum = sum(list1)
    print(sum)

Submission status: Accepted

Solution code:
import os

def main():
	num, count = map(int, input().split())
	hp_list = list(map(int, input().split()))
	hp_list.sort(reverse=True)
	print(sum(hp_list[count:]) if count != 0 else sum(hp_list))
	
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[:-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.sort()
print(sum(H[:max(N-K, 0)]))

Submission status: Accepted

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

Submission status: Accepted

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

H_sorted = sorted(Hn,reverse=True)
H_sorted[:K]=[0]*K

print(sum(H_sorted))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#入力:N(int:整数)
def input1():
	return int(input())

#入力:N,M(int:整数)
def input2():
	return map(int,input().split())

#入力:[n1,n2,...nk](int:整数配列)
def input_array():
	return list(map(int,input().split()))


H,K=input2()
h=input_array()

if K>=H:
	print(0)
elif K<=0:
	print(sum(h))
else:
	sorted_h=sorted(h)
	print(sum(sorted_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:
    n = sorted(H, reverse=True)[K:]
    print(sum(n))

Submission status: Accepted

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

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

sum=0
if K>=N:
  print(sum)
else:
  for i in range(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()))
A = sorted(H)
if len(A) <= K:
    print(0)
else:
    print(sum(A[0:len(A)-K]))

Submission status: Accepted

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

h_list = [int(s) for s in input().split()]
h_list.sort()
if k > 0:
    h_list = h_list[:-k]

ans = sum(h_list)
print(ans)

Submission status: Accepted

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

H = [-h for h in H]
heapify(H)
for _ in range(K):
    if len(H) == 0:
        break
    heappop(H)

print(-sum(H))

Submission status: Accepted

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

count = 0
if k<n:
  num = sorted(num)
  num = num[::-1]
  for i in range(k,n):
    count = count + num[i]
  print(count)
  exit()
print(count)

Submission status: Accepted

Solution code:
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,  K = input().split()
mon = list(map(int,input().split()))
mon = sorted(mon,reverse=True)
#print(mon)
K = int(K)
num = K-1
#print(mon)
#print(mon[K:])
ATC = sum(mon[K:])
print(ATC)

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[0:n-k]))

Submission status: Accepted

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

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

    h_sum = 0

    for i in h:
        h_sum += i

    print(h_sum)

Submission status: Accepted

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

H = sorted(H)
if K==0:
    print(sum(H))
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()
for i in range(k):
    if len(h_list) > 0:
        h_list.pop()
print(sum(h_list))

Submission status: Accepted

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

if len(H)<=K:
    print(0)
else:
    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()
if N>K:
    for _ in range(K):
        H.pop()
    print(sum(H))
else:
    print(0)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
import math
def print_ans(N, K, ar):
    """Test Case
    >>> print_ans(3, 1, [4, 1, 5])
    5
    >>> print_ans(8, 9, [7, 9, 3, 2, 3, 8, 4, 6])
    0
    >>> print_ans(3, 0, [1000000000, 1000000000, 1000000000])
    3000000000
    """
    if K >= len(ar):
        print(0)
    elif K == 0:
        print(sum(ar))
    else:
        ar = sorted(ar)
        print(sum(ar[:-K]))

if __name__ == '__main__':
    N, K = map(int, input().rstrip().split())
    ar = list(map(int,input().rstrip().split()))
    print_ans(N, K, ar)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

count = 0
H = sorted(H,reverse=True)

count += sum(H[K:])

print(count)

Submission status: Accepted

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


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 = sum(H)
choniki = 0
H_sorted = sorted(H, reverse=True)

if K >= len(H):
	print(0)
else:
	for i in range (0, K):
		choniki+=H_sorted[i]
	print(h-choniki)

Submission status: Accepted

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

H.sort(reverse=True)

print(sum(H[K:]))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,k = map(int, input().split())
monsters = list(map(int, input().split()))
monsters = sorted(monsters)
count = 0
if len(monsters) <= k:
    print("0")
    exit()

for i in range(k):
    monsters.pop(-1)


for j in monsters:
    count += j
print(count)

Submission status: Accepted

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

if K>=N:
	print(0)
	exit()
#HPの多い順に必殺技を使用
H.sort()
for i in range(K):
	H[N-1-i]=0
    
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()    
H.sort()
for i in range(K):
	H[N-1-i]=0
    
print(sum(H))

Submission status: Accepted

Solution code:
enemy,skill=map(int,input().split())
hp=list(map(int,input().split()))
if skill>enemy:
    print(0)
else:
    hp.sort()
    for i in range(skill):
        del hp[-1]
    print(sum(hp))

Submission status: Accepted

Solution code:
import sys
import math

from collections import defaultdict
from collections import deque
def load(vtype=int):
    return vtype(input().strip())
def load_list(seplator=" ", vtype=int):
    return [vtype(v) for v in input().strip().split(seplator)]
def exit():
    import sys
    sys.exit(0)
def perm_sub(li, used):
    if len(li) == len(used):
        return [deque()]
    k = []
    for i in range(len(li)):
        if i in used:
            continue
        used.add(i)
        sub_list = perm_sub(li, used)
        for sub in sub_list:
            sub.appendleft(li[i])
        k.extend(sub_list)
        used.discard(i)
    return k
def perm_li(li):
    return perm_sub(li, set())
def perm_n(n):
    return perm_sub(list(range(n)), set())
def join_i(li, sep=""):
    return sep.join([str(e) for e in li])
def li2n(li):
    n, base = 0, 1
    for i in range(len(li)-1, -1, -1):
        n += li[i] * base
        base *= 10
    return n
def sli2ili(li):
    return [int(s) for s in li] 
def prime_list(n):
    li = [i for i in range(2, n+1)]
    for i in range(len(li)):
        if li[i] >= int(math.sqrt(n)):
            break
        if li[i] == -1:
            continue
        for j in range(i+1, len(li)):
            if li[j] % li[i] == 0:
                li[j] = -1
    return [n for n in li if n != -1]
def gcd(a, b):
    a, b = max(a, b), min(a, b)
    while True:
        r = a % b
        if r == 0: return b
        a, b = b, r
def lcm(a, b):
    return int(a * b / gcd(a,b))
def all_subset(li):
    s = []
    n = len(li)
    for bit in range(0, (1<<(n+1))):
        ss = set()
        for i in range(0, n):
            if (bit & (1 << i)):
                ss.add(li[i])
        s.append(ss)
    return s
def factorial(n):
    if n == 1:
        return 1
    return n * factorial(n-1)
def mCn(m, n):
    def factorial_ntimes(m, n):
        r = 1
        while n:
            r *= m
            m -= 1
            n -= 1
        return r
    return int(factorial_ntimes(m, n) / factorial(n))

n, k = load_list()
H = load_list()

h = list(reversed(sorted(H)))
print(sum(h[k:]))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
lists = list(map(int, input().split()))
if K == 0:
    print(sum(lists))
    exit()

if K <= len(lists):
    # for i in range(K):
    #     max_lists = lists.remove(max(lists))
    lists = sorted(lists)[:N - K]
    print(sum(lists))
    exit()
else:
    print(0)
    exit()

# print(lists)

Submission status: Accepted

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

if n <= k:
  print(0)
else:
  res = 0
  for i in range(k, n):
    res += List[i]
  print(res)

Submission status: Accepted

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

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

print(answer)

Submission status: Accepted

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

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