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

Submission status: Accepted

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

Submission status: Accepted

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

H.sort(reverse=True)

if len(H) <= K:
    print(i)
else:
    del H[:K]
    i += sum(H)
    print(i)

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:
input_list = list(map(int, input().split()))
monster_num = input_list[0]
atk_times = input_list[1]
hps_list = list(map(int, input().split()))
sort_hp_list = sorted(hps_list, reverse=True)
if monster_num < atk_times:
  print(0)
else:
  print(sum(sort_hp_list[atk_times: ]))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = min(len(b),a[1])
b.sort()
del b[a[0] - c:a[0]]
print(sum(b))

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()
    l = h[0:(n-k)]

    print(sum(l))

Submission status: Accepted

Solution code:
a=[int(i) for i in input().split()]
b=[int(i) for i in input().split()]
if a[1]>=a[0]:
    print(0)
else:
    print(sum(sorted(b)[:a[0]-a[1]]))

Submission status: Accepted

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

H.sort()

H_= H[:-K]


if N==K:
  print(0)
elif K==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 K == 0:
  print(sum(H))
else:
  H.sort(reverse = True)
  if N>K:
    h = H[K:N]
    print(sum(h))
#    for i in range(K):
 #     del H[i]
  #  print(sum(H))
  else:
    print(0)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

A_list = list(A)
counter = 0
A_list.sort()
A_list.reverse()

if K >= N:
    print(0)
else:
    for val in range(N - K):
        counter += int(A_list[val+K])
    print(counter)

Submission status: Accepted

Solution code:
n, k= map(int, input().split())
h = list(map(int, input().strip().split()))
import numpy as np
hnp = np.asarray(h)
hnp = np.sort(hnp, axis=0)      
if(k >= n):
    print(int(0))
else:    
    s = n-k
    print(int(np.sum(hnp[:s])))

Submission status: Accepted

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

a.sort()

counter = 0
if K >= len(a):
  counter = 0
else:
  for _ in range(K):
      a.pop(-1)
  counter = sum(a)
print(counter)

Submission status: Accepted

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

count = 0

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

print(count)

Submission status: Accepted

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

if k >= len(h):
    H = []
else:
    H = h[k:]

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

H = sorted(H, reverse=True)

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

Submission status: Accepted

Solution code:
import numpy as np

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

x = np.array(list(map(int, input().split())))

if N <= K:
	print(0)
else:
	x = np.sort(x)[::-1]
	print(int(np.sum((x[K:]),dtype=np.float64)))

Submission status: Accepted

Solution code:
N, K = input().split()
N = int(N)
K = int(K)
H = input().split()
H = [int(h) for h in H]
H.sort(reverse = True)
# print(H)
I = K if K <= N else N
for i in range(0, I):
    H[i] = 0
# print(H)
print(sum(H))

Submission status: Accepted

Solution code:
n, k = map(int, input().split(" "))
h = [int(h) for h in map(int, input().split(" "))]
h = sorted(h)
if k <= len(h):
	for i in range(k):
		h.pop()
	sum = sum(h)
else:
	sum = 0

print(sum)

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

Submission status: Accepted

Solution code:
h,n=map(int,input().split())
m=list(map(int, input().split()))
m.sort(reverse=True)
del m[:n]
a=0

for i in range(len(m)):
  a=a+m[i]
  
print(a)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10**9)

h, k = map(int, input().split())
hi = list(map(int, input().split()))
hi.sort(reverse=True)
del hi[:k]

num = 0
if hi == []:
    print(0)
else:
    for i in hi:
        num += i
    print(num)

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
l=list(map(int,input().split()))
if m<n:
  l.sort()
  for i in range(m):
    l.pop(len(l)-1)
  print(sum(l))
else:
  print(0)

Submission status: Accepted

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

h = list(map(int,input().split()))
h.sort()
s=0
t=0

if k == 0:
  for i in h:
    s += i
  print(s)
elif k >= n:
  print(0)

  
else:
  k= k*(-1)
  h = h[:k]
  for j in h:
    t += j
  print(t)

Submission status: Accepted

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

Submission status: Accepted

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

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

hh.sort()

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

Submission status: Accepted

Solution code:
# coding: utf-8

import sys
input=sys.stdin.readline

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

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

Submission status: Accepted

Solution code:
a = input()
l = a.split()
n = int(l[0])
k = int(l[1])
b = input()
ll = b.split()
for i in range(0,n):
    ll[i] = int(ll[i])
if n<k+1:
    print(0)
else:
    p = 0
    ll.sort()
    for i in range(0,n-k):
        p = p + ll[i]
    print(p)

Submission status: Accepted

Solution code:
import heapq

enemy_list = [int(i) for i in input().split()]
hp_list = [int(i) for i in input().split()]

if enemy_list[0] == enemy_list[1]:
    print(0)
elif enemy_list[1] == 0:
    print(sum(hp_list))
else:
    print(sum(heapq.nsmallest((len(hp_list) - enemy_list[1]), hp_list)))

Submission status: Accepted

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

if N <= K:
    res = 0
else:
    n_num = [int(n_str) for n_str in x]
    n_num_sorted = sorted(n_num, reverse=True)
    res = sum(n_num_sorted[K:])

print(res)

Submission status: Accepted

Solution code:
import heapq

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

print(sum(H)-sum(heapq.nlargest(K, H)))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,k = (int(x) for x in input().split())
h=list(int(x) for x in input().split())
h = sorted(h,reverse=True)
if n<k:
    print("0")
elif k == 0:
    print(sum(h))
else:
    n = h[k:]
    print(sum(n))

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

def must_attack():
	H.sort()
	for i in range(K):
		if len(H) > 0:
			H.pop()
	sum_damage = 0
	for i in H:
		sum_damage += i
	return sum_damage

ans = must_attack()
print(ans)

Submission status: Accepted

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

cnt = 0

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

  cnt += sum(H)

  print(cnt)

Submission status: Accepted

Solution code:
nk = [int(i) for i in input().split()]
sum = 0

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

for i in range(nk[1], nk[0]):
  sum += list[i]

print(sum)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

H.sort(reverse=True)

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

Submission status: Accepted

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

if N > K :

	if K != 0: 
		H = H[:-K]
	print(sum(H))
else:
	print("0")

Submission status: Accepted

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

if n<=k:
  print(0)
elif k==0:
  print(sum(s))
else:
  s.sort()
  print(sum(s[0:-k]))

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
s = []
for i in range(2):
    s.append(input().split())
n = int(s[0][0])
k = int(s[0][1])
answer = 0
hs = s[1]
h = [int(a) for a in hs]
h.sort()
h.reverse()
if(k<n):
    for i in range(k,n):
        answer = answer + h[i]
print(answer)

Submission status: Accepted

Solution code:
a = input().split(" ")
bl = input().split(" ")
b = []
for num in bl:
  b.append(int(num))
b.sort(reverse = True)
N = int(a[0])
K = int(a[1])

m=0
i=0
if len(b) <= K:
  print(0)
else:
  for h in range(K,len(b)):
    i = i + b[h]
  print(i)

Submission status: Accepted

Solution code:
# def sort(A):
#     if len(A) < 2:
#         return A
#     c = len(A)//2
#     return merge(sort(A[:c]), sort(A[c:]))

# def merge(X, Y):
#     if len(X) < 1:
#         return Y
#     if len(Y) < 1:
#         return X
#     if (X[0] < Y[0]):
#         return [Y[0]]+ merge(X, Y[1:])
    # else:
#         return [X[0]] + merge(X[1:], Y)

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

Submission status: Accepted

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

if K>=N:
  print("0")
else:
  H_min=sorted(H)[:c]
  ans=sum(H_min)
  print(ans)

Submission status: Accepted

Solution code:
# coding: utf-8
import heapq
n,k = [int(x) for x in input().split()]
h = sorted([int(x) for x in input().split()])
#print(h)
s = 0
if k >= n:
    print(0)
else:
    h = h[:n-k]
    for j in h:
        s += j
    print(s)

Submission status: Accepted

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

Submission status: Accepted

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

if __name__=='__main__':
    if (K>=N):
        print(0)
    elif K==0:
        print(sum(H))
    else:
        H=sorted(H,reverse=True)
        print(sum(H[K:N]))

Submission status: Accepted

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

#h(n)
h=list(map(int, input().split()))
#美しくないが降順ソートして代入
hi=sorted(h,reverse=True)

cnt=0

#美しくないがkの数分、配列の位置をずらす
#敵より必殺技の数の方が多いケースがあるのでif文を入れる
if k >= len(hi):
    i = len(hi)
else:
    i = k

#ん～。ださい
while (i<len(hi)):
    cnt += hi[i]
    i += 1

print(cnt)

Submission status: Accepted

Solution code:
import sys

def main():
    k = int(input().replace('\n','').split()[1])
    tmp = list(map(int,input().replace('\n','').split()))
    tmp.sort(reverse=True)
    n=0
    for i in tmp[k:]:
        n+=int(i)
    print(n)
if __name__ == '__main__':
    input = sys.stdin.readline
    main()

Submission status: Accepted

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

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

if len(H) != 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()

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

Submission status: Accepted

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

h.sort(reverse=True)


count = 0
for v in h[k:]:
    count += v
print(count)

Submission status: Accepted

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

print(sum(N[K:]))

Submission status: Accepted

Solution code:
inp = input().rstrip().split(" ")
N = int(inp[0])
K = int(inp[1])
inp = input().rstrip().split(" ")
HP = [0 for i in range(N)]
for i in range(N):
  HP[i] = int(inp[i])
HP.sort()
HP.reverse()
ans = 0
for i in range(N):
  if i >= K:
    ans += HP[i]
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

if(K >= len(H)):
    print(0)
else:
    for i in range(i, len(H)):
        sum += H[i];
    print(sum)

Submission status: Accepted

Solution code:
X = list(map(int, input().split()))
Y = list(map(int, input().split()))

N = X[0]
K = X[1]

S = sorted(Y, reverse=True)

S[:K] = []

print(sum(S))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,K=(int(x) for x in input().split())
H=list(map(int, input().split()))
A = sorted(H)
i=0
a=N-K
if K >= N:
    print('0')

else:
    B=A[:a]
    C=sum(B)
    print(C)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
##C
N,K = map(int,input().split())
H = list(map(int,input().split()))
ans = 0
for i , val in enumerate(sorted(H,reverse = True)):
    if i+1 > K:
        ans += val
print(ans)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
N,K = input().split()
N = int(N)
K = int(K)

H = input().split()
H = [int(s) for s in H]
H.sort(reverse=True)

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

  sumdata = 0
  for i in range(0,len(H)):
    sumdata += H[i]
  print(sumdata)

Submission status: Accepted

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

HP = sum(H)
ld = sorted(H , reverse=True)
if K >= len(H):
    print(0)

else:
    Z = sum(ld[:K])
    hp = HP - Z
    print(hp)

Submission status: Accepted

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

list.sort(A, reverse=True)
if K<=N:
    for i in range(K):
        A[i]=0
elif K>=N:
    for i in range(N):
        A[i]=0
print(sum(A))

Submission status: Accepted

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

for i in range(N):
  H_int.append(int(H[i]))

H_int_sorted = sorted(H_int)

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

Submission status: Accepted

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

H = list(map(int, input().split()))
H_s = sorted(H, reverse=True)

print(sum(H_s[K:]))

Submission status: Accepted

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

H.sort(reverse=True)
#print(H)

count = 0

if(K<N):
  for i in range(K,N):
    count+=H[i]
    #print(i)

print(count)

Submission status: Accepted

Solution code:
# finding the biggest k values

import heapq

def c():
    
    n, k = map(int, input().split())
    if k >= n:
        return 0

    healths = list(map(int, input().split()))
    heapq.heapify(healths)

    res = 0
    for _ in range(n - k):
        res += heapq.heappop(healths)

    return res


def main():
    res = c()
    print(res)

    
# function call 
main()

Submission status: Accepted

Solution code:
import numpy as np
N, M = map(int, input().split())


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

count=0
if N>=M:
    for i in range(N-M):
        count+=A[i]
    print(count)



else:
    print(0)

Submission status: Accepted

Solution code:
from heapq import heapify, heappop
from math import ceil
N, K = map(int, input().split())
H = list(map(int, input().split()))
# N=8
# K=9
# H=[7, 9, 3, 2, 3, 8, 4, 6]

Hminus = list(map(lambda x: x*(-1), H))
# print(type(Hminus))
heapify(Hminus)
# print(Hminus)
if K > len(H):
    print(0)
else:
    for _ in range(K):
        heappop(Hminus)
    print(sum(Hminus)*(-1))

Submission status: Accepted

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

a.sort()
attack = 0

for i in range(c[0]-c[1]):
  attack += a[i]

print(attack)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# https://atcoder.jp/contests/abc153/tasks/abc153_c
import numpy as np
N, K = map(int, input().split())
H = np.array(list(map(int, input().split())), dtype='int64')
H.sort()
# print('H', H)
if N <= K:
    print(0)
    exit()
if K == 0:
    print(H.sum())
    exit()
subset = H[:-K]
# print(subset)
print(subset.sum())

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,K = list(map(int, input().split(" ")))
H = sorted(list(map(int, input().split(" "))), reverse=True)
Z = 0
R = 0
for n,e in enumerate(H):
  if (n == K):
    Z = n
    break
  elif (K >= len(H)):
    Z = len(H)
    break
for i in H[Z:]:
  R += i
print(R)

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):
    h[0:k] = []
    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(reverse=True)
c=len(H)
if c<=K:
    count=0
else:
    H2=H[K:]
    count=sum(H2)
print(count)

Submission status: Accepted

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

    print(sum(monsters[:-k]) if k != 0 else sum(monsters))


if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
H = [int(x) for x in 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())
h = list(map(int, input().split()))

ans = 0

if k >= n:
  ans = 0
else:
  h_sort = sorted(h, reverse=True)
  for i in range(k, len(h_sort)):
    ans += h_sort[i]

print(ans)

Submission status: Accepted

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

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

MONS.sort()

if K == 0:
    print(sum(MONS))
else:
    if len(MONS) <= K:
        print(0)
    else:
        for _ in range(K):
            MONS.pop(-1)
        print(sum(MONS))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import numpy as np

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

if K < len(H):
    print(np.sum(H[K:]))
else:
    print(0)

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(1000000000)

def dfs(i, special):
    if (i > N - 1):
        return 0
    if (special > 0):
        return dfs(i + 1, special - 1)
    else:
        return  MONSTERS[i] + dfs(i + 1, special)       

N, K = map(int, input().split())
MONSTERS = map(int, input().split())
MONSTERS = list(reversed(sorted(MONSTERS)))
print(dfs(0, K))

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
j=n-1
s=0
for i in range(k):
    a[j]=0
    j=j-1
    if(j<0):
        break
for i in range(n):
    s=s+a[i]
print(s)

Submission status: Accepted

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

b.sort(reverse=True)
ans = 0

del b[:k]
n -= k

if n < 0:
    print('0')
else:
    print(sum(b))

Submission status: Accepted

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

d.sort()
d.reverse()
del d[0:k]

print(sum(d))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a,b=map(int,input().split())
c=[int(x) for x in input().split()]
d=sorted(c)
for i in range(b):
    del d[-1]
    if d==[]:
        break
print(sum(d))

Submission status: Accepted

Solution code:
kazu, hissatu = map(int,input().split())
hairetu = list(map(int,input().split()))

toru = kazu-hissatu

if toru<=0:
  print(0)
else:
  hairetu.sort()
  print(sum(hairetu[:(kazu)-hissatu]))

Submission status: Accepted

Solution code:
i = list(map(int, input().split()))
j= list(map(int, input().split()))
x=sorted(j, reverse=True)
z=0
 
if i[1]>=len(j):
  print(0)
else:
  for a in range(i[1],len(x)):
    z+=x[a]
  print(z)

Submission status: Accepted

Solution code:
n_ene, n_special = map(int, input().split())
hps = list(map(int, input().split()))

if n_special >= n_ene:
    print(0)
else:
    hps.sort(reverse=True)
    hps = hps[n_special:]
    print(sum(hps))

Submission status: Accepted

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

count = 0

if N<K:
    print(0)
else:
    # リストをソートする
    H_list = sorted(H_list, reverse=True)
    # 上位K位をスライスで削除
    H_list = H_list[K:]


    # リスト内の残りの数を合計
    count = sum(H_list)
    print(count)

Submission status: Accepted

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

# sort
A.sort(reverse=True)
if (len(A) < N):
    print(0)
else:
    print(sum(A[N:]))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,M = map(int,input().split())
A =list(map(int,input().split()))
new_list = sorted(A, reverse=True)
ans = 0

del new_list[0:M]
        
if not new_list:
    print(ans)
else:
    ans +=sum(new_list)
    print(ans)

Submission status: Accepted

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

    print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

ans = -1

# print(h)

if n<=k:
  ans = 0
elif n>k:
  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()))

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

Submission status: Accepted

Solution code:

n, k = (int(x) for x in input().split())
h_list = list(map(int, input().split()))

# 体力の多い順に並べ替え
h_list.sort(reverse = True)

temp_k = k
sum_normal_attack = 0

while temp_k < n:
    sum_normal_attack = sum_normal_attack + h_list[temp_k]
    temp_k = temp_k + 1

print(sum_normal_attack)

Submission status: Accepted

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


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

Submission status: Accepted

Solution code:
import numpy as np
H, K = map(int, input().split())
H = np.array([int(num) for num in input().split()])
H_sort = np.sort(H)[::-1]
print(int(H_sort[K:].sum()))

Submission status: Accepted

Solution code:
# import numpy as np
# import math
# import copy
# from collections import deque
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(10000)


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

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

    print(res)



main()

Submission status: Accepted

Solution code:
attack=list(map(int,input().split()))
damage=list(map(int,input().split()))
A=0

N=attack[0]
K=attack[1]
damage.sort(reverse=True)

if N>K:
  del damage[:K]
  print(sum(damage))

else:
  print(0)

Submission status: Accepted

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

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

# k回必殺技を使って敵を減らす
# 強い敵から殺したい, sortする
h.sort()

for i in range(k):
  if h != []:
    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(reverse=True)
if k != 0:
    H.sort(reverse=True)
    del H[:k]
print(sum(H))

Submission status: Accepted

Solution code:
i=list(map(int,input().split()))
j=list(map(int,input().split()))
c=0
cnt=1
n=i[1]
j.sort(reverse=True)
for x in j:
  if cnt>n:
    c+=x
  else:
    cnt+=1
print(str(c))