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

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

Submission status: Accepted

Solution code:
import sys

def main():

    # sys.stdin = open('input153c.txt')

    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)

if __name__ == '__main__':
    main()

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys


def solve():
    input = sys.stdin.readline
    mod = 10 ** 9 + 7
    n, k = list(map(int, input().rstrip('\n').split()))
    h = list(map(int, input().rstrip('\n').split()))
    h.sort()
    t = 0
    for i in range(n - k):
        t += h[i]
    print(t)


if __name__ == '__main__':
    solve()

Submission status: Accepted

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

H = sorted(H, key= lambda x:-x)[K:]
print(sum(H))

Submission status: Accepted

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

for i in range(K):
    if len(H)!=0:
        H.remove(max(H))
        #print(H)
    else:
        #print(0)
        break
print(sum(H))'''

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())
a=sorted(list(map(int,input().split())),reverse=True)
print(sum(a[k:]))

Submission status: Accepted

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

H.sort(reverse=True)
attack_count = 0

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

print(attack_count)

Submission status: Accepted

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

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

Submission status: Accepted

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

def main():
    N,K = map(int,input().split())
    A = list(map(int,input().split()))
    l = len(A)
    A.sort(reverse = True)
    if K >= l:
        print(0)
    else:
        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(key=lambda x:-x)
ans = 0
if k >= n:
    print(0)
else:
    print(sum(h[k:]))

Submission status: Accepted

Solution code:
def solve(n, k, h):
    if k == 0:
        return sum(h)
    else:
        return sum(sorted(h)[:-min(n, k)])

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

Submission status: Accepted

Solution code:
import math

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

atk = 0

H.sort()

for i in range(N - K):
    atk += H[i]

print(atk)

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

Submission status: Accepted

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

if k>=n:
	print(0)
else:
	print(sum(numbers[:n-k]))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math

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

H.sort()
n = N - K if N - K > 0 else 0

print (sum(H[0:n]))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

h.sort()
n -= k
if k > len(h):
    for i in range(len(h)):
        h.pop()
else:
    for i in range(k):
        h.pop()

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

print(ans)

Submission status: Accepted

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


for i in range(N - K ):
    ans += Hs[i]

print(ans)

Submission status: Accepted

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

h.sort()
h.reverse()

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

Submission status: Accepted

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

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

    print(sum(h)-critical)

Submission status: Accepted

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

Submission status: Accepted

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

print(x)

Submission status: Accepted

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

if K >= N:
    print(0)
else:
    sum = [0]
    for i in range(0, N):
        #print(sum, H[i], sum[i-1], i)
        sum.append(sum[i]+H[i])

    #print(sum)
    print(sum[N]- sum[K])

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

Submission status: Accepted

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

H.sort(reverse=True)

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

print(sum)

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

Submission status: Accepted

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

Submission status: Accepted

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

for i in range(N):
    if i + 1 <= K:
        continue
    ans = ans + H[i]

print(ans)

Submission status: Accepted

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

b.sort()

if n>=a:
  print(0)
  exit()

if n==0:
  print(sum(b))
  exit()
  
c=b[:-1*n]

print(sum(c))

Submission status: Accepted

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

Submission status: Accepted

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

if __name__ == '__main__':
    N, K = map(int, input().rstrip().split())
    H = list(map(int, input().rstrip().split()))
    if K >= N:
        print(0)
    else:
        sorted_H = sorted(H, reverse=False)[:N-K]
        print(sum(sorted_H))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
enemyNum,hissatsu = map(int, input().split())
point = input().split()
point = sorted(point, key = int)
count = 0
if enemyNum - hissatsu <= 0:
  print(0)
else:
  for i in range(enemyNum - hissatsu):
    count += int(point[i])
  print(count)

Submission status: Accepted

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

Submission status: Accepted

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

k = k[n:]
 
print(sum(k))

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

Submission status: Accepted

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

A.sort()

ans = 0

for i in range( H - K ):
  ans += A[i]
  
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
monstar,hisatu= map(int,input().split())
m_life=list(map(int,input().split()))

m_life.sort()
count =0

for i in range(len(m_life)-hisatu):
    count += m_life[i]
print(count)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
monster, hisatu = map(int, input().split())
m_life = list(map(int, input().split()))
m_life.sort()
count = 0
for i in range(len(m_life)-hisatu):
    count += m_life[i]
print(count)

Submission status: Accepted

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

Submission status: Accepted

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


#sort
H.sort(reverse=True)

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

# 攻撃の回数
res = 0
h = sorted(h, reverse=True)

for hh in h:
    if k > 0:
        k -= 1
    else:
        res += hh
print(res)

Submission status: Accepted

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

s = sorted(h)
ans = 0

c = n[0] - n[1]

if c > 0:
  for i in range(c):
    ans = s[i] + ans

print(ans)

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

Submission status: Accepted

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

array.sort()
total = 0

for i in range(n-k):
    total +=  array[i]


print(total)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

H.sort(key=lambda x: -x)

c = min(K, N)

i = 0
while 0 < c:
    H[i] = 0
    c -= 1
    i += 1

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
n,k = map(int, sys.stdin.readline().split())
a = list(map(int, sys.stdin.readline().split()))
if n<=k:
    print(0)
elif k==0:
    print(sum(a))
else:
    a.sort()
    print(sum(a[:-k]))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,k = map(int,input().split())
a = list(map(int,input().split()))
a.sort(reverse=1)
ans = 0
for i in range(k,n):
    ans += a[i]
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import heapq
n, k = [int(i) for i in input().split()]
h = [-int(i) for i in input().split()]
res = -sum(h)
heapq.heapify(h)

for i in range(min(k, n)):
    res += heapq.heappop(h)

print(max(0, res))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

N, K, *H = map(int, open(0).read().split())

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

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

Submission status: Accepted

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

a.sort()

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
n, k = map(int,input().split())
h = [int(i) for i in input().split()]
"""
if k >= n:
    ans = 0
else:
    h.sort()
    tmp = 0
    for i in range(n-k, n):
        tmp += h[i]
    ans = (sum(h) - tmp)
print(ans)
"""

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
n, k = map(int,input().split())
h = [int(i) for i in input().split()]

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

Submission status: Accepted

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

ans = 0
for h in H:
    if K > 0:
        K -= 1
    else:
        ans += h

print(ans)

Submission status: Accepted

Solution code:
# coding utf-8
import math

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

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

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

print(ans)

Submission status: Accepted

Solution code:
num,SPAttackNum =map(int,input().split())

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

for i in range(min(SPAttackNum,num)):
    hpList.pop()

print(sum(hpList))

Submission status: Accepted

Solution code:
a=input().rstrip().split(" ")
b=input().rstrip().split(" ")

c=[]

for i in range(int(a[0])):
  c.append(int(b[i]))

d=sorted(c)

S=0

for j in range(int(a[0])-int(a[1])):
  S += d[j]

print(S)

Submission status: Accepted

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

Submission status: Accepted

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

print(sum(h[k:]))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

n_attack = sum(hs[k:]) if k < n else 0
print(n_attack)

Submission status: Accepted

Solution code:
import sys

input = sys.stdin.readline

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

Hs = sorted(map(int, input().split()))

print(sum(Hs[:-K if K > 0 else len(Hs)]))

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 sys
import heapq
input = sys.stdin.readline

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

Hs = [-int(c) for c in input().split()]
heapq.heapify(Hs)

for _ in range(min(K, len(Hs))):
    heapq.heappop(Hs)

print(-sum(Hs))

Submission status: Accepted

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

Submission status: Accepted

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

H.sort()

for i in range(0,K):
    if H:
      H.pop()

print(sum(H))

Submission status: Accepted

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

h_sorted = sorted(h,reverse=True)

# print(h_sorted)

h_remaining = h_sorted[k:]

ans = sum(h_remaining)

print(ans)

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,k,*a=map(int,open(0).read().split());a.sort();print(sum(a[:max(n-k,0)]))

Submission status: Accepted

Solution code:
n, k = map(int,input().split())
h_inst = list(input().split())
h = []
for i in range(n):
    h.append(int(h_inst[i]))
h.sort()
atk = n-k
num = 0
for i in range(atk):
    num += h[i]

print(num)

Submission status: Accepted

Solution code:
List = []
b = 0

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

for i in range(len(H)):
    a = int(H[i])
    List.append(a)
    
List.sort()

for i in range(K):
    List.pop()
    if len(List) == 0:
        break
        
for i in range(len(List)):
    b = b + List[i]

print(b)

Submission status: Accepted

Solution code:
from sys import stdin
N, K = [int(_) for _ in stdin.readline().rstrip().split()]
H = sorted([int(_) for _ in stdin.readline().rstrip().split()], reverse=True)
print(sum(H[K:]))

Submission status: Accepted

Solution code:
import math
def IN(): return map(int,input().split())
ans = 0; mod = pow(10,9)+7
n,k=IN()
A=sorted(list(IN()))
for i,a in enumerate(A):
  if i<n-k:ans+=a
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[k:])
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

H.sort()
ans = 0
for i in range(n-k):
    ans += H[i]

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

H = sorted(H, reverse=True)

print(sum(H[K:]))

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
from itertools import product, permutations, combinations
from bisect import bisect_right,bisect_left
INF = float('inf')

N, K=map(int, input().split())
HP=sorted(list(map(int, input().split())), reverse=True)
cnt = 0
for i in range(N):
    if K > 0:
        K -= 1
        continue
    cnt += HP[i]

print(cnt)

Submission status: Accepted

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


def main():
    n, k = map(int, input().split())
    h = sorted(list(map(int, input().split())), reverse=True)
    count = 0
    ans = 0

    for hi in h:
        if count >= k:
            ans += hi

        count += 1

    print(ans)


if __name__ == '__main__':
    main()

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:
  print(sum(A[:(N-K)]))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n, k = map(int, input().strip().split())
a = sorted(map(int, input().split()), key= lambda x: -x)
print(sum(a) - sum(a[:k]))

Submission status: Accepted

Solution code:
from heapq import nsmallest

N, K = map(int, input().split())
H = (int(x) for x in input().split())

print(sum(nsmallest(N - K, H)))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
monster_num, spattack_num = input().split()

monster_num = int(monster_num)

spattack_num = int(spattack_num)

hplist = list(input().split())

hplist = list(map(int, hplist))

hplist = sorted(hplist, reverse=True)

value = 0

if spattack_num >= monster_num:
    print(0)
else:
    for i in range(spattack_num):
        hplist[i] = 0

    for i in range(monster_num):
        value = value + hplist[i]

    print(value)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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 = sorted(h, reverse=True)
ans = sum(h_sort[k:])

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

Submission status: Accepted

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

ans = 0

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

Submission status: Accepted

Solution code:
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N,K = MI()
    H = LI()
    H.sort(reverse=True)
    print(sum(H[K:]))

if __name__ == '__main__':
    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()
    print(sum(h[:n-k]))

Submission status: Accepted

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

Submission status: Accepted

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

for i in range(n):
    if k:
        k -= 1
    else:
        ans += monster[i]

print(ans)

Submission status: Accepted

Solution code:
def solve(string):
    n, k, *h = map(int, string.split())
    return str(sum(sorted(h)[:max(n - k, 0)]))


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))

Submission status: Accepted

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

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

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

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

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