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:
#ABC153-C
N,K=map(int,input().split())
H=[int(i) for i 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)
print(sum(H[K:]))

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
h = list(map(int, input().split()))
h.sort()
# print(h)
for ind in range(k):
    if len(h) != 0:
        h.pop(-1)   
print(sum(h))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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:
from collections import deque
x,y = map(int, input().split())
li = list(map(int, input().split()))
li.sort(reverse=True)
q = deque(li)
if y >= len(li):
    print(0)
else:
    for i in range(y):
        q.popleft()
    s = 0
    for i in range(len(q)):
        s += q[i]
    print(s)

Submission status: Accepted

Solution code:
def main():
    num, k = map(int, input().split())
    a = list(map(int, input().split()))
    a = sorted(a, reverse=True)
    sum_attack = sum(a[k:])
    print(sum_attack)


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 K > N:
  K = N
for i in range(K):
  H[i] = 0

print(sum(H))

Submission status: Accepted

Solution code:
#template
from collections import Counter
def inputlist(): return [int(j) for j in input().split()]
N,K = inputlist()
H = inputlist()
H.sort()
H.reverse()
ans = 0
for i in range(K,N):
    ans += H[i]
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

A=sorted(H,reverse=True)
B=(A[k:n])
print(sum(B))

Submission status: Accepted

Solution code:
def q3():
    H,K = (int(i) for i in input().split())
    H = [int(i) for i in input().split()]
    H = sorted(H, reverse=True)
    ans = sum(H[K:])
    print(ans)

if __name__ == '__main__':
    q3()

Submission status: Accepted

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

if K > len(H):
    del H[:]

else:
    for j in range(K):
        del H[-1]
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)
print(sum(h[k:]))

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
h = [int(i) for i in input().split()]
h.sort()
del h[-1:-ｋ-1:-1]
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)
del h[0:k]
print(sum(h))

Submission status: Accepted

Solution code:
from collections import deque
from collections import Counter
from itertools import product, permutations,combinations
from operator import itemgetter
from heapq import heappop, heappush
from bisect import bisect_left, bisect_right, bisect
#pypyではscipy, numpyは使えない
#from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson, minimum_spanning_tree
#from scipy.sparse import csr_matrix, coo_matrix, lil_matrix
#import numpy as np
from fractions import gcd
from math import ceil,floor, sqrt, cos, sin, pi, factorial
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**8)
INF = float('inf')
from datetime import datetime as dt

def main():
  n,k = map(int, readline().split())
  h = list(map(int, readline().split()))
  if n<=k:
    print(0)
  else:
    h.sort(reverse=True)
    ans = sum(h[k:])
    print(ans)
  
  
if __name__ == '__main__':
  main()

Submission status: Accepted

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

monster_list = sorted(H, reverse=True)[:K]
ans = sum(H) - sum(monster_list)

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:
h, a = map(int, input().split(" "))
aL = sorted(list(map(int, input().split(" "))), reverse=True)

print(sum(aL[a:]))

Submission status: Accepted

Solution code:
from collections import deque

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

A=list(map(int,input().split()))
A.sort(reverse=True)
A=A[K:]

print(sum(A))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby
    #from itertools import product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

L=[]
for i in l:
    if k>0 :
        k-=1
    else:
        L.append(i)

S=sum(L)
print(S)

Submission status: Accepted

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

Submission status: Accepted

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

H.sort()
for i in range(K):
    if len(H):
        H.pop()
print(sum(H))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

cnt = 0
for i in range(K, N):
    cnt += H[i]
print(cnt)

Submission status: Accepted

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

Submission status: Accepted

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

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(N):
  if K > 0:
    K -= 1
  else:
    ans += H[i]
print(ans)

Submission status: Accepted

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

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 = sorted(H, reverse=True)
kH = H[K:]
print(sum(kH))

Submission status: Accepted

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

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

h.sort()

if n<k:
  k=n

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

print(sum(h))

Submission status: Accepted

Solution code:
import numpy as np
n,k = map(int,input().split())
num_list = list(map(int,input().split()))
ans = 0
num_list = np.sort(num_list)[::-1]
num_list = np.array(num_list)

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

Submission status: Accepted

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

Submission status: Accepted

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


def solve(N: int, K: int, H: "List[int]"):
    print(sum(sorted(H, reverse=True)[K:]))
    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(reverse=True)
del H[0:K]

print(sum(H))

Submission status: Accepted

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

Submission status: Accepted

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

y=sorted(x,reverse=True)

print(sum(y[n:]))

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=[int(i) for i in input().split(" ")]
H=[int(i) for i in input().split(" ")]
H.sort()
H.reverse()
print(sum(H[K:]))

Submission status: Accepted

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

H.sort()
for n in range(K):
    if H==[]:
        break
    H.pop()

print(sum(H))

Submission status: Accepted

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

Submission status: Accepted

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

H.sort(reverse=True)
for i in range(K):
    H[i] = 0
    if i+1 == N:
        break

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

Submission status: Accepted

Solution code:
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

n,k = iim()
H = sorted(iil(),reverse=True)[k::]
print(sum(H))

Submission status: Accepted

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

sum_attack = sum(h[k:])
print(sum_attack)

Submission status: Accepted

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

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

Submission status: Accepted

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

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

print(sum(move))

Submission status: Accepted

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

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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def main():
    N, K = map(int, input().split())
    H = list(map(int, input().split()))
    tmp = list(sorted(H))
    tmp1 = list(reversed(tmp))

    print(sum(tmp1[K:]))
    #print("")

main()

Submission status: Accepted

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

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

if n <= k:
    print(0)

else:
    h.sort()
    ans = sum(h[0:n-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
import numpy

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

h = numpy.array(h)
h *= -1
h = list(h)
heapq.heapify(h)

for i in range(k):
    if i > n-1:
        break
    heapq.heappop(h)
print(sum(h)*-1)

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

Submission status: Accepted

Solution code:
import heapq
n,k = map(int,input().split())
hlist = list(map(lambda x: int(x)*(-1),input().split()))

heapq.heapify(hlist)
if k < n:
  for i in range(k):
    heapq.heappop(hlist)
  print(-sum(hlist))
else:
  print(0)

Submission status: Accepted

Solution code:
import sys

n,k=map(int,input().split())
s=list(map(int,input().split()))
s.sort(reverse=True)

if k<len(s):
  for i in range(k):
    s[i]=0
else:
  for i in range(n):
    print(0)
    sys.exit()

print(sum(s))

Submission status: Accepted

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

#print(n)
a = list(map(int, input().split()))

sum = 0
a.sort()
#print(a)
for i in range(min(n,k)): a.pop()
#print(a)
for i in range(len(a)):
    sum += a[i]
print(sum)

Submission status: Accepted

Solution code:
readline = input().split()
monsters = input().split()
n = int(readline[0])
k = int(readline[1])
ans = 0

for i in range (n):
    monsters[i] = int(monsters[i])

monsters.sort()

if (k < n):
    for i in range (n - k):
        ans += monsters[i]

print(ans)

Submission status: Accepted

Solution code:
nk = list(map(int,input().split()))
n,k = nk
h = list(map(int,input().split()))
if k >= len(h):
    print(0)
else:
    h.sort()
    for i in range (k):
        h.pop()
    print(sum(h))

Submission status: Accepted

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

Submission status: Accepted

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

y=sorted(H)
y.sort(reverse=True)
x=0

for i in range (K,N):
    x=x+y[i]
    
print(x)

Submission status: Accepted

Solution code:
import sys

x = sys.stdin.readline()
x = x.split(' ')
(n,k)=[int(str) for str in x]

h = sys.stdin.readline()
h = h.split(' ')
h = [int(str) for str in h]
h = sorted(h,reverse=True)

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

print(sum)

sys.stdout.flush()

Submission status: Accepted

Solution code:
tmp = list(input().split())
H = int(tmp[0])
K = int(tmp[1])

tmp = list(input().split())

for i in range (H) :
    tmp[i] = int(tmp[i])

tmp = sorted(tmp)

sum = 0

for i in range (H - K) :
    sum += tmp[i]

print (sum)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# 初期入力
N,K = (int(x) for x in input().split(" "))
H = list(map(int, input().split()))
tuujou_attack = 1

# N種類のモンスター、K回の必殺技、モンスターは　H　の体力
# 体力の多いモンスターから必殺技で倒す。必殺技が使えなくなったら通常攻撃
nokori_kaisu = 0
H_sorted = sorted(H)
if N <= K:
    nokori_kaisu = 0
else:
    nokori_hissatuwaza = N -K
    # del H_sorted[nokori_hissatuwaza:]
    nokori_kaisu = sum( H_sorted[:nokori_hissatuwaza] ) # 体力少ないほうから　N-K　まで、通常攻撃「１」

print(nokori_kaisu)
# print(H_sorted)

Submission status: Accepted

Solution code:
# 初期入力
N,K = (int(x) for x in input().split(" "))
H = list(map(int, input().split()))
tuujou_attack = 1

# N種類のモンスター、K回の必殺技、モンスターは　H　の体力
# 体力の多いモンスターから必殺技で倒す。必殺技が使えなくなったら通常攻撃
nokori_kaisu = 0
H_sorted = sorted(H)
if N <= K:
    nokori_kaisu = 0
else:
    nokori_hissatuwaza = N -K
    del H_sorted[nokori_hissatuwaza:]
    nokori_kaisu = sum( H_sorted ) # 体力少ないほうから　N-K　まで、通常攻撃「１」

print(nokori_kaisu)

Submission status: Accepted

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

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

heapq.heapify(H)

for i in range(K):
    heapq.heappop(H)

print(sum(H)*(-1))

Submission status: Accepted

Solution code:
from sys import exit

N, K = map(int, input().split())
monsters = [int(i) for i in input().split()]
if N <= K:
  print(0)
  exit()
monsters.sort()
attack = 0
for i in range(N - K):
  attack += monsters[i]
print(attack)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
m_count, s_count = map(int, input().split())
monsters = list(map(int, input().split()))
monsters.sort(reverse=True)
del monsters[0:s_count]
count = sum(monsters)
print(count)

Submission status: Accepted

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

h = list(map(int, input().split()))
#print(h)
h.sort()
#print("sorted = ", h)
h.reverse()
#print(h)
score = 0
for i in range(k, n):
	score = score + h[i]
print(score)

Submission status: Accepted

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

li.sort()

ans = 0

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

for i in range(n-k):
    ans += li[i]
    
print(ans)

Submission status: Accepted

Solution code:
x = [int(x) for x in input().split()]
line = [int(x) for x in input().split()]

line.sort(reverse = True)

if x[0] <= x[1]:
    print(0)
else:
    print(sum(line[x[1]:]))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

print(total)

Submission status: Accepted

Solution code:
n,k = map(int,input().split())
h = sorted(list(map(int,input().split())))
for i in range(k):
  if i == n:
    break
  h.pop(-1)
print(sum(h))

Submission status: Accepted

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

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

Submission status: Accepted

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

h = sorted(h, reverse=True)

del h[:k]

print(sum(h) if h != 0 else 0)

Submission status: Accepted

Solution code:
a=input().split()
(n,m)=map(int,a)
b=input().split()
b1=list(map(int,b))
b1=sorted(b1)
for i in range(m):
    b1[len(b)-1-i]=0
    if i==len(b1)-1:
        break

print(sum(b1))

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
h = list(map(int, input().split()))
h.sort()
ans = 0
if len(h) == n:
    for i in range(k):
        try:
            h.pop()
        except:
            pass
    for x in h:
        ans += x
    print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math 

nk = input().split()
hl = input().split()


n = int(nk[0])
k = int(nk[1])

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

	h = sorted([int(i) for i in hl])
	hp = 0

	for i in hl:
		hp = hp + int(i)



	for i in range(k):
		hp = hp - int(h[-1-i])

	print(hp)

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:
'''
    Auther: ghoshashis545 Ashis Ghosh
    College: jalpaiguri Govt Enggineerin College
    Date:23/03/2020
'''


from math import ceil
def main():
    
    
    
    n,m=map(int,input().split())
    
    a=list(map(int,input().split()))
    a.sort()
    ans=0
    for i in range(n-m):
        ans+=a[i]
    print(ans)
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
if __name__ =="__main__":
    main()

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
nk=input().rstrip().split(" ")
n=int(nk[0])
k=int(nk[1])
hps=input().rstrip().split(" ")
for i in range(n):
    hps[i]=int(hps[i])
shps=sorted(hps)
#print(shps)
answer=0
for i in range(n-k):
    answer+=int(shps[i])
print(answer)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

power = sorted(power, reverse=True)

print(sum(power[K:]))

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()
for i in range(k):
    h.pop()
print(sum(h))

Submission status: Accepted

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

Submission status: Accepted

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

HP = sum(h[min(n,k):n])
print(HP)

Submission status: Accepted

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

for i in range(min(n, k)):
        del h[n - i - 1]

HP = sum(h)
print(HP)

Submission status: Accepted

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

for i in range(k):
    if n > i:
        del h[n - i - 1]

HP = sum(h)
print(HP)

Submission status: Accepted

Solution code:
data = input().split()
 
n = int(data[0])
k = int(data[1])
 
hpstr = input().split()
hp = []
 
for i in range(n):
  hp.append(int(hpstr[i]))
 
hp.sort()
 
ans = 0
for i in range(n - k):
  ans += hp[i]
 
print(ans)

Submission status: Accepted

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

h.sort(reverse=True)

ans = sum(h[min(k,n):n])

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

a.sort(reverse=True)

del a[:m]

ans = sum(a)

print(ans)

Submission status: Accepted

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

h = sorted(h)

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

print(b)

Submission status: Accepted

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

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

Submission status: Accepted

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

print(sum(s[k:]))

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
A,B = map(int,input().split())
num_list= list(map(int,input().split()))

#print(num_list)
sort_num_list = sorted(num_list)

if B >= len(num_list):
  print(0)
else:
  for i in range(B):
    test = sort_num_list.pop()
  print(sum(sort_num_list))

Submission status: Accepted

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

h_lst = sorted(h_lst, reverse=-1)
print(sum(h_lst[k:]))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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:
n,h=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
a.reverse()
c=[0]*2
c[0]=h
c[1]=len(a)
for k in range(0,min(c)):
  a[k]=0
print(sum(a))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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()
  count = 0
  for _ in range(len(h) - k):
    count += h[_]
  print(count)

Submission status: Accepted

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

al = l[k:]
print(sum(al))

Submission status: Accepted

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

ll=sorted(l,reverse=True)

ll=ll[b:]
print(sum(ll))