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

if a<=b:
  print(0)
else:
  print(sum(l[b:]))

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
n, k = map(int, input().split())
h = list(map(int, input().split()))

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import math

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

H.sort(reverse=True)

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

Submission status: Accepted

Solution code:
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from bisect import bisect_right, bisect_left
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from copy import deepcopy
from math import factorial, ceil, floor, gamma, log
from operator import mul
from functools import reduce


sys.setrecursionlimit(2147483647)
INF = float('INF')
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 10 ** 9 + 7


n, k = LI()
H = sorted(LI())
if k >= n:
    print(0)
else:
    print(sum(H[:n - k]))

Submission status: Accepted

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

N, K = list(map(int, input().split()))
h_list = list(map(int, input().split()))
h_list = sorted(h_list, reverse=True)

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

print(ans)

Submission status: Accepted

Solution code:
N,K=map(int, input().split())
LH=list(map(int, input().split()))
sumH=sum(LH)
count=0
LH.sort()
LH.reverse()

sumH-=sum(LH[0:K])
count+=sumH
print(count)

Submission status: Accepted

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

if len(h) <= k:
    print(0)
    exit(0)

print(sum(h[k:]))

Submission status: Accepted

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

    for i in range(k):
        h_list.pop()
        if not h_list:
            print(0)
            return
    ans = sum(h_list)
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

# 必殺技で倒す数
SkillKill = len(SM[:K])

remain = N - SkillKill
if remain > 0:
  print(sum(SM[K:]))
else:
  print(0)

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

Submission status: Accepted

Solution code:
d = input().split(" ")
n = int(d[0])
k = int(d[1])
h = input().split(" ")
for i in range(n):
	h[i] = int(h[i])
if k >= n:
	print(0)
else:
	s = 0
	h.sort()
	for i in range(n-k):
		s += h[i]
	print(s)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

count = 0
h.sort(reverse=True)

for i in range(k, n, 1):
    count += h[i]

print(count)

Submission status: Accepted

Solution code:
data = list(map(int, input().split()))
lst = sorted(list(map(int, input().split())), reverse=True)

N = data[0]
K = data[1]

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

print(a)

Submission status: Accepted

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

while b>0 and len(monster)>0:
    monster.pop()
    b-=1
print (sum(monster))

Submission status: Accepted

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

atack_num = 0
for hp in h:
    if k > 0:
        k -= 1
    else:
        atack_num += hp

print(atack_num)

Submission status: Accepted

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

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

mylist = sorted(mylist, reverse=True)

print(sum(mylist[K:]))

Submission status: Accepted

Solution code:
N, K = 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:
N,K = map(int,input().split())
H = sorted(list(map(int,input().split())),reverse=True)
ans = sum(H[K:])
print(ans)

Submission status: Accepted

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

new = sorted(li, reverse=True)

count = 0

for i in new:
  if K > 0:
    K -= 1
  else:
    count += i

print(count)

Submission status: Accepted

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

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

print(sum)

Submission status: Accepted

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

Submission status: Accepted

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

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

    ans = sum(H)
    print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:

n, k = [int(i) for i in input().split()]
t=[int(i) for i in input().split()]
t = sorted(t)
a = 0
for i in range(n-k):
	a+=t[i]
print(a)

Submission status: Accepted

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

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

Submission status: Accepted

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

if k == 0:
	print(sum(h))
else:
	print(sum(sorted(h)[:-k]))

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
# coding: utf-8

import sys

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

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

H.sort()

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

del H[len(H) - K :]

print(sum(H))

Submission status: Accepted

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

if len(H) <= k:
    print(0)
else:
    print(sum(H[0:n - k]))

Submission status: Accepted

Solution code:
import heapq

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

print(sum(heapq.nsmallest(max(0, N - K), H)))

Submission status: Accepted

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

Submission status: Accepted

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

H.sort(reverse = True)

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
n,k=(int(x) for x in input().split())
h=list(map(int,input().split()))
h.sort()
count=0
for i in range(len(h)-k):
    count+=h[i]
print(count)

Submission status: Accepted

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

N,K=acinput()
H=sorted(acinput(),reverse=True)

res=0
for i in range(N):
    if i>=K:
        res+=H[i]

print(res)

Submission status: Accepted

Solution code:
import heapq

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

ans = 0
heapq.heapify(H)
for _ in range(N - K):
    ans += heapq.heappop(H)

print(ans)

Submission status: Accepted

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

import sys
import math


debug = False

def log(text):
    if debug:
        print(text)

def parse_input(lines_as_string = None):

    global debug
    lines = []
    if lines_as_string is None:
        debug = False
        # for line in sys.stdin:
        #     lines.append(line)
        lines.append(input())
        lines.append(input())
    else:
        debug = True
        lines = [e for e in lines_as_string.split("\n")][1:-1]


    (n, k) = [int(e) for e in lines[0].split(' ')]
    h = [int(e) for e in lines[1].split(' ')]

    return (n, k, h)


def solve(n, k, h):

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

    return sum(remained)


def main():
    # 出力
    result = solve(*parse_input())
    if isinstance(result, list):
        for r in result:
            print("%s" % r, sep='')
    else:
        print("%s" % result, sep='')

if __name__ == '__main__':

    main()

Submission status: Accepted

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

H_i.sort(reverse = True)

sum = 0

for i in range(K, N):
    sum += H_i[i]

print(sum)

Submission status: Accepted

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

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

# 敵の体力を降順でソート
sorted_H = sorted(H, reverse=True)

# 最初のK体の敵は必殺技で倒す
new_H = sorted_H[K:]

print(sum(new_H))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n, k = map(int,input().split())
li = list(map(int,input().split()))
li.sort()
for i in range(k):
    if li != []:
        li.pop()
print(sum(li))

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
K = min(N, K)
H =list(map(lambda x: - int(x), input().split()))
#print(H)
import heapq
heapq.heapify(H)
for i in range(K):
  heapq.heappop(H)
ans = 0
for i in range(N - K):
  ans += - heapq.heappop(H)
print(ans)

Submission status: Accepted

Solution code:
import sys

N, K = map(int, sys.stdin.readline().split())
H =list(map(int, sys.stdin.readline().split()))

sH = sorted(H, reverse = True)

sum = 0
if K > N:
    print(0)
else:
    for i in range(K, N):
        sum += sH[i]
    print(sum)

Submission status: Accepted

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

ans = 0

if len(H) <= K:
    print(0)
else:
    H.sort(reverse=True)
    for i in range(K):
        H[i] = 0
    
    print(sum(H))

Submission status: Accepted

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

H.sort(reverse = True)
H = sum(H[K:])
print(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[k:]))

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

Submission status: Accepted

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

ans = 0
Hn.sort()
try:
    for _ in range(K):
        Hn.pop(-1)
except:
    print(0)
    exit()
ans = sum(Hn)
print(ans)

Submission status: Accepted

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

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

h.sort(reverse=True)

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

print(ans)

Submission status: Accepted

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

H.sort(reverse=True)

if len(H) <= K:
    print('0')
else:
    del H[:K]
    print(sum(H))

Submission status: Accepted

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

### TESTCASE
test = ""
#test = \
"""
3 1
4 1 5
ans 5
"""

"""
8 9
7 9 3 2 3 8 4 6
ans 0
"""

"""
3 0
1000000000 1000000000 1000000000
ans 3000000000
"""
############
test = list(reversed(test.strip().splitlines()))
if test:
    def input2():
        return test.pop()
else:
    def input2():
        return input()
####### MAIN

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

sorth = sorted(h)

for i in range(min(n, k)):
    sorth.pop()

print(sum(sorth))

Submission status: Accepted

Solution code:
n, k  = map(int, input().split())
h = sorted(map(int, input().split()))
# print(h)
if k >= len(h):
    k = len(h)
for _ in range(k):
    h.pop(-1)

answer = sum(h)
print(answer)

Submission status: Accepted

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

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

if N <= K:
    print(0)
    exit()
H.sort(reverse=True)
for i in range(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(reverse = True)

if k > n:
  k = n

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

if N <= K:
    ans = 0
else:
    num = N - K
    ans = sum(H[:num])

print(ans)

Submission status: Accepted

Solution code:
f = lambda:map(int,input().split())
n, k = f()
l = sorted(list(f()))
print(sum(l[:n-k]) 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)
ans = 0

for i in h:
    if k > 0:
        k -= 1
    else:
        ans += i

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import numpy as np
def resolve():
    n, k = map(int, input().split())
    h = list(map(int, input().split()))
    h = np.sort(h)[::-1]
    total = 0
    for i in range(n):
        if i < k:
            continue
        else:
            total += h[i]
    print(total)
resolve()

Submission status: Accepted

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

H.sort()

if K == 0:
    ans = sum(H)
else:
    ans = sum(H[:(-1 * K)])
    
print(ans)

Submission status: Accepted

Solution code:
def quick_sort(list):
    stand=list[0]
    over=[]
    same=[]
    under=[]
    for i in list:
        if(i>stand):
            over.append(i)
        elif(i<stand):
            under.append(i)
        else:
            same.append(i)
    if(len(over)>1):
        over=quick_sort(over)
    else:
        pass
    if(len(under)>1):
        under=quick_sort(under)
    else:
        pass

    return over+same+under

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

Submission status: Accepted

Solution code:
def solve(N, K, healths):
  healths_sorted = sorted(healths, reverse=True)
  print(sum(healths_sorted[K:]))


def iln(): return list(map(int, input().split()))


N, K = iln()
healths = iln()
solve(N, K, healths)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys
n,k = map(int, input().split())
hlist = list(map(int, input().split()))
hlist.sort(reverse=True)
total = 0
if k >= n:
    print(0)
    sys.exit()
else:
    for i in range(k,n):
       total += hlist[i]
    print(total)

Submission status: Accepted

Solution code:
N, Hissatsu = map(int, input().split())
HP = list(map(int, input().split()))
HP.sort()
count = max(N-Hissatsu, 0)

if (count > 0):
    count = sum(HP[:count])

print(count)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n = input()    
m = n.split()
p = [int(i) for i in m] 
n = input()    
m = n.split()
q = [int(i) for i in m] 
q.sort(reverse=True)
A = 0
for i, value in enumerate(q):
    if i < p[1]:
        pass
    else:
        A = A + value
print(A)

Submission status: Accepted

Solution code:
import math

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

h_list.sort(reverse=True)

print(sum(h_list[k:n+1]))

Submission status: Accepted

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

H.sort()
print(sum(H[0:max(0, N - K)]))

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, K = [int(i) for i in input().split()]
Hs = [int(i) for i in input().split()]
Hs.sort(reverse=True)
print(sum(Hs[K:]))

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

Submission status: Accepted

Solution code:
a,b=map(int,input().split())
l=list(map(int,input().split()))
l.sort()
c=0
for i in range(a-b):
    c+=l[i]
print(c)

Submission status: Accepted

Solution code:
import math 

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

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

    count = 0
    for h in H:
        count += h
    
    print(count)

if __name__ == "__main__":
    main()

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#C - Fennec vs Monster
N,K = map(int,input().split())
H = list(map(int, input().split()))
ans = 0
H.sort(reverse=True)

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

print(ans)

Submission status: Accepted

Solution code:
from functools import reduce

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

# process
H.sort()
if N <= K: ans = 0
else: ans = reduce(lambda x, y: x+y, H[0:N-K])

# output
print(ans)

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

Submission status: Accepted

Solution code:
def main():
    n, k = map(int, input().split(" "))
    monster = [int(s) for s in input().split(" ")]
    monster.sort(reverse=True)
    attack = 0
    for i in range(k, n):
        attack += monster[i]
    print(attack)


if __name__ == '__main__':
    main()

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.sort(reverse=True)

print(sum(H[K:]))

Submission status: Accepted

Solution code:
import numpy as np
N, K = (int(i) for i in input().split())  
H = [int(i) for i in input().split()]

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

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

Submission status: Accepted

Solution code:
a, b = map(int, input().split())
l = [int(x) for x in input().split()]

l.sort()
i = a - 1

for x in range(b):
    l[i] = 0
    i -= 1

    if i < 0:
        break

print(sum(l))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
N,K=map(int,input().split())
H=[int(a) for a in input().split()]
H.sort(reverse=True)

K=min(N,K)
tmp=H[K:]

print(sum(tmp))

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
# 2020/01/26
# AtCoder Beginner Contest 153 - C

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

# Sort Desc.
h.sort()
h.reverse()

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

# Output
print(ans)

Submission status: Accepted

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

    ct = 0

    hps = sorted(hps)
    hps.reverse()

    if len(hps) <= k:
        print(0)
        return

    hps = hps[k:]

    remain = sum(hps)

    print(remain)




if __name__ == "__main__":
    main()

Submission status: Accepted

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

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

Submission status: Accepted

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

del h[0:k]

print(sum(h))

Submission status: Accepted

Solution code:
"""
NTC here
"""
import sys
inp= sys.stdin.readline
input = lambda : inp().strip()
flush= sys.stdout.flush
# import threading
# sys.setrecursionlimit(10**6)
# threading.stack_size(2**25)

def iin(): return int(input())
def lin(): return list(map(int, input().split()))

# range = xrange
# input = raw_input


def main():
    n, k = lin()
    a = lin()
    a.sort(reverse=True)
    for i in range(min(k, n)):
        a[i]=0
    
    print(sum(a))



            
        

        
main()
# threading.Thread(target=main).start()

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

H.sort()

kill = min(N, K)

H = H[0:N-kill]

print(sum(H))

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

H.sort()
s = 0

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

Submission status: Accepted

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

if (len(A)-K)>=0:
    h=A[0:(len(A)-K)]
    print(sum(h))
else:
    print(0)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:


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

t = min(n, k)
# print(t)
# print(h[0:t])
ans = sum(h[0:(n-t)])
print(ans)

# print(len(h))
# print(h)
# print(h[0:1])
# print(h[0:2])
# print(h[1:2])

Submission status: Accepted

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

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

tmp = 0

if n <= k:
    print(0)

else:
    h.sort(reverse=True)

    for i in range(k, len(h)):
        tmp += h[i]
    
    print(tmp)

Submission status: Accepted

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

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

H.sort()
print(sum(H[0:len(H)-K]))

Submission status: Accepted

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

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

H.sort(reverse= True)

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

Submission status: Accepted

Solution code:
#!python3.4.3

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() ))
J=[]
import heapq

for i in range(N):
  J.append((-1)*H[i])

heapq.heapify(J)
for l in range(K):
  if l <N:
    heapq.heappop(J)
  
print((-1)*sum(J))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    from sys import stdin, setrecursionlimit
    #setrecursionlimit(10**9)
    #n = int(stdin.readline()[:-1])   
    r = stdin.readline()[:-1]
    #r = [stdin.readline() for i in range(n)]
    #t = [int(stdin.readline()) for i in range(n)]
    #n = int(r)
    #a = r.split()
    #a,b,c = r.split()
    #a = list(map(int, r.split()))
    n,k = map(int, r.split())
    r = stdin.readline()[:-1]
    a = list(map(int, r.split()))
    #a = [int(s[i]) for i in range(1, n+1)]
    #a = [list(map(int, r.split())) for i in range(1,n+1)]
    #res = 0

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

if __name__ == '__main__':
    main()

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

S = sum(Hs[K:])

print(S)

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

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
N, K = map(int, input().split())
H = list(map(int, input().split()))

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