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:
import heapq

n, k = map(int, input().split())
h = [-1 * int(i) for i in input().split()]
heapq.heapify(h)

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

for i in range(k):
    heapq.heappop(h)

print(-1*sum(h))

Submission status: Accepted

Solution code:
N, K = map(int, input().split(' '))
H = list(map(int, input().split()))
H.sort(reverse=True)
res = 0
for i in range(K, len(H)):
  res += H[i]

print(res)

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

Submission status: Accepted

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

h_sorted = sorted(h, reverse=True)

for i in range(k):
    if i>n-1:
        break
    h_sorted[i] = 0

rest = sum(h_sorted)

print(rest)

Submission status: Accepted

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

print(solve())

Submission status: Accepted

Solution code:
#########行列読み込み ##############################################
"""
from sys import stdin
n = int(stdin.readline().rstrip())
data = [stdin.readline().rstrip().split() for _ in range(n)]
print(data)
print(*data, sep='\n')
"""
##################################################################
#########入力系####################################################
"""
s =input()
s=list(input())
a=int(input())
x,y = map(int,input().split())	
li = input().split()	
li = list(map(int,input().split()))	
li = input().split('T')	
"""
##################################################################
N, K = map(int,input().split())
#A = [0]*N
H = sorted(list(map(int,input().split())),reverse=True)	
if len(H)<=K:
    print("0")
else:
    del H[0:K]
    print(sum(H))

Submission status: Accepted

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

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

Submission status: Accepted

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

H.sort(reverse=True)

ans = 0
for i in H[K:N]:
    ans += i

print(ans)

Submission status: Accepted

Solution code:
H, N = list(map(int, input().split()))
a = list(map(int, input().split()))
a.sort(reverse=True)
minus = 0 
if N >= H:
  num = H
else:
  num = N


for i in range(num):
  minus+= a[i]
print(sum(a)-minus)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
INT_MAX=10**11+7
MOD=10**9+7
def INPUT():return list(int(i) for i in input().split())
def LIST_1D_ARRAY(n):return [0 for _ in range(n)]
def LIST_2D_ARRAY(m,n):return [[0 for _ in range(n)]for _ in range(m)]
#=======================================================================
import math as M
n,k=INPUT()
A=INPUT()
A.sort()
sum=0
for i in range(n-k):
    sum+=A[i]
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=1)
if N < K:
    K = N
for i in range(K):
    H[i] = 0
print(sum(H))

Submission status: Accepted

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

print(sum(H[K:]))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

H.sort(reverse = True)

print(sum(H[K:]))

Submission status: Accepted

Solution code:
N, K = [int(x) for x in input().split()]
H = sorted([int(x) for x in input().split()], reverse=True)
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(reverse=True)
count = 0
for i in range(K, N):
    Hi = H[i]
    count += Hi
print(count)

Submission status: Accepted

Solution code:
#!/usr/bin python3
# -*- coding: utf-8 -*-

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

H.sort() 


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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

print(H_sum)

Submission status: Accepted

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

Submission status: Accepted

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

if K >= N:
    print(0)
else:
    A = sorted([int(i) for i in input().split()])
    print(sum(A[:N-K]))

Submission status: Accepted

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

if K >= N:
    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()))

if k >= len(h):
  print(0)
else:
  h_sorted = sorted(h, reverse=True)
  print(sum(h_sorted[k:]))

Submission status: Accepted

Solution code:
import sys
import os
import math
import string
import collections

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

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

lcm = lambda x, y: x * y / math.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


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

    N, K = il()
    H = il()
    H = sorted(H, reverse=True)
    print(sum(H[K:]))


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

H.sort(reverse=True)
k=0
if N<=K:
  K=N
for i in range(K):
  H[i]=0

print(sum(H))

Submission status: Accepted

Solution code:
from collections import deque

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

d=deque(sorted(Monsters,reverse=True))

for k in range(K):
    if len(d)!=0:
        d.popleft()

print(sum(d))

Submission status: Accepted

Solution code:
n,k=[int(x) for x in input().split()]
arr=[int(x) for x in input().split()]
s=0
arr.sort()
if(n>k):
    for i in range(n-k):
        s+=arr[i]
    print(s)
else:
  print(0)

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:N-K]))

Submission status: Accepted

Solution code:
n,k = map(int,input().split())
a = list(map(int,input().split()))
b = sorted(a)
if n <= k:
  print(0)
else:
  c = 0
  t = 0
  while t < n-k:
    c += b[t]
    t += 1
  print(c)

Submission status: Accepted

Solution code:
import numpy as np
n, k = map(int,input().split())
h = np.array(input().split(),dtype=int)

h.sort()
sum = 0
for i in range(n-k):
    sum += h[i]
print(sum)

Submission status: Accepted

Solution code:
import sys
n, k = map(int, sys.stdin.readline().split())
li = list(map(int, sys.stdin.readline().split()))
l = len(li)
t = 0
if l > k:
  li.sort()
  li.reverse()
  t = sum(li[k:])
print(t)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
N, K = map(int, input().split())
H = sorted(list(map(int, input().split())), reverse = True)
print(sum([H[i] for i in range(K, N)]))

Submission status: Accepted

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

s.sort()

for i in range(min(len(s),k)):
    s.pop()

ans = 0
for i in s:
    ans += i

print(ans)

Submission status: Accepted

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

attack = 0

if k>=n:
  print(attack)

elif k<n:
  print(sum(hn[0:n-k]))

Submission status: Accepted

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

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
import sys

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

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

h.sort()

if k >= n:
  print(0)
  sys.exit()

h = h[:n-k]

print(sum(h))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
#template
def inputlist(): return [int(k) for k in input().split()]
#template
N,K = inputlist()
H = inputlist()
if K >= N:
    print(0)
    exit()
H.sort(reverse=True)
ha = H[K:]
print(sum(ha))

Submission status: Accepted

Solution code:
a, b = map(int,input().split())
c = list(map(int,input().split()))
d = []

i = a - b

d = sorted(c)

e = sum(d[:i])



if a <= b:
	print("0")
else:
  	print(e)

Submission status: Accepted

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

#攻撃:hを1減らす　必殺技:hをすべて減らす制限　k回
#hを降順にソート
h.sort(reverse = True)
#nがkより小さい時全部に必殺技が使えるから0
if n <= k:
    print(0)
#体力が多い順に必殺技を使用して残った体力の合計を出力
else:
    for i in range(k):
        h[i] = 0
    print(sum(h))

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
#https://atcoder.jp/contests/abc153/tasks/abc153_c

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

Submission status: Accepted

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

Submission status: Accepted

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

H.sort(reverse = True)
SUM = 0
for i,v in enumerate(H):
    if i >= K:
        SUM+= v
print(SUM)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,k = (int(x) for x in input().split())
if k>n:
    k = n
h_list = [int(i) for i in input().split()]

h_list.sort()

ans = sum(h_list[0:n-k])
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

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

for i in range(K):
    H.pop(-1)

print(sum(H))

Submission status: Accepted

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

L.sort()
if K > N:
    print(0)
else:
    print(sum(L[:N-K]))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
import itertools

n,k=map(int,input().split())
l = list(map(int,input().split()))[:n]

if k >= n:print(0);exit()

l.sort()

if k > 0:
    print(sum(l[:-k]))
else:
    print(sum(l))

Submission status: Accepted

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

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

Submission status: Accepted

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

# 体力の大きい順にソート
h=sorted(h,reverse=True)

# k > len(h) ならば　空のリストになるので
# k >= len(h) と　それ以外の場合分けが必要なくなる
h=h[k:]
print(sum(h))

Submission status: Accepted

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

# hを体力の小さい順にソート
h.sort()

# 全てのモンスターに必殺技を使える場合
if k >= len(h):
    print('0')
# 全てのモンスターに必殺技を使えない場合
# 体力の大きいモンスター順からk体削除
else:
    new_h = h[:len(h)-k]
    print(sum(new_h))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

if K >= N:
    print(0)
else:
    H.sort()
    H_new = H[:N-K]

    print(sum(H_new))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
H=[int(y) for y in input().split()]
A=[int(y) for y in input().split()]
A.sort(reverse=True)
if H[1]>len(A):
    A=[]
else:
    for x in range(H[1]):
          A[x]=0

print(sum(A))

Submission status: Accepted

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

h.sort()
for i in range(k):
    if len(h) == 0:
        break
    else:
        h.pop(-1)
print(sum(h))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
enemy,special=map(int,input().split())
hps=list(map(int,input().split()))
hps=sorted(hps,reverse=True)
print(sum(hps[special:]))

Submission status: Accepted

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

def calculate(n,k,arr):
    result = 0
    arr = sorted(arr)
    for i in range(n-k):
        result = result + arr[i]

    print(result)

calculate(N,K,ARR)

Submission status: Accepted

Solution code:
def main():
    N, K = map(int, input().split())
    H = [int(h) for h in input().split()]
    H = sorted(H, reverse=True)
    if len(H) <= K:
        print(0)
    else:
        print(sum(H[K:]))
if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import numpy as np
N, K = map(int, input().split())
H_list = np.array(list(map(int, input().split())))

if K >= N:
    print(0)
else:
    H_list_sorted = np.sort(H_list)
    print(sum(H_list_sorted[:N-K]))

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

ans = 0
for n, i in enumerate(list_h):
    if k > 0:
        k = k - 1
        list_h[n] = 0
    else:
        break

ans = ans + sum(list_h)
print(ans)

Submission status: Accepted

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

    for i in range(k):
        if i >= len(monsters):
            break
        monsters[i] = 0
    print(sum(monsters))

if __name__ == '__main__':
    main2()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
stdin = open(0).read().split('\n')
N, K = map(int,stdin[0].split())
A = list(map(int,stdin[1].split()))
B = sorted(A)
ans = 0
for i in range(max(0,N-K)):
    ans += B[i]
print(ans)

Submission status: Accepted

Solution code:
n,k,*h=map(int,open(0).read().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()))
if len(h)<=k: print('0')
else: print(sum(sorted(h,reverse=True)[k:]))

Submission status: Accepted

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

h.sort()

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

Submission status: Accepted

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


def solve(N: int, K: int, H: "List[int]"):
    if K >= N:
        return 0
    return sum(sorted(H, reverse=True)[K:])


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    H = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    print(solve(N, K, H))

if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#153 Fennec vs Monster
n,k = map(int,input().split())
tairyoku = list(map(int,input().split()))
tairyoku.sort(reverse=True)

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def Main(N, K, H):
    H.sort()
    if N <= K:
        return 0
    else:
        return sum(H[:N-K])

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

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

H.sort() # 昇順

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

print(ans)

Submission status: Accepted

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

count = sum(H[K:])

print(count)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import deque, Counter as cnt
from collections import defaultdict as dd
from operator import itemgetter as ig
from bisect import bisect_right as bsr
from math import factorial, ceil, floor
import sys
sys.setrecursionlimit(1000000)

# お約束
args = None
INF = float("inf")
MOD = int(1e9 + 7)


def input(*ps):
    if type(ps[0]) is list:
        return [input(*ps[0][:-1]) for _ in range(ps[0][-1])]
    elif len(ps) == 1:
        return ps[0](next(args))
    else:
        return [p(next(args)) for p in ps]


def nlist(n, v):
    if not n:
        return [] if type(v) is list else v
    return [nlist(n[1:], v) for _ in range(n[0])]


def yesno(v, yes="Yes", no="No", upper=False):
    if upper:
        print([yes.upper(), no.upper()][not v])
    else:
        print([yes, no][not v])


def main():
    """エントリーポイント"""
    N, K = input(int, int)
    H = input([int, N])
    H.sort()
    if N <= K:
        print(0)
        return
    if K == 0:
        print(sum(H))
        return
    print(sum(H[:-K]))


if __name__ == '__main__':
    args = iter(sys.stdin.read().split())
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

#HPが多い敵を上からk体だけ減らす。
H.sort(reverse=True);
yowa = H[k:];

ans = sum(yowa);

print(ans);

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
h=list(map(int,input().split()))
h=sorted(h)
for i in range(k):
  if len(h)==0:
    break
  del h[-1]
hit=sum(h)
print(hit)

Submission status: Accepted

Solution code:
N,K=map(int,input().split())
H=list(map(int,input().split()))
if N<K or N==K:
    print(0)
    exit(0)
else:
    list.sort(H)
for n in range(K):
    H.pop()
print(sum(H))

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
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 = list(map(int, input().split()))
H = list(map(int, input().split()))

a = 0
b = 0
if N <= K:
    ans = 0
else:
    a = N - K

H.sort()
for i in range(a):
    b += H[i]
print(b)

Submission status: Accepted

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


# 入力を整数に変換して受け取る
def input_int():
    return int(input())


# マイナス1した値を返却
def int1(x):
    return int(x) - 1


# 半角スペース区切り入力をIntに変換してMapで受け取る
def input_to_int_map():
    return map(int, input().split())


# 半角スペース区切り入力をIntに変換して受け取る
def input_to_int_tuple():
    return tuple(map(int, input().split()))


# 半角スペース区切り入力をIntに変換してマイナス1した値を受け取る
def input_to_int_tuple_minus1():
    return tuple(map(int1, input().split()))


def main():
    n, k = input_to_int_map()
    h = input_to_int_tuple()

    if n <= k:
        return 0

    h_sorted = sorted(h)
    return sum(h_sorted[:n - k])


if __name__ == "__main__":
    print(main())

Submission status: Accepted

Solution code:
from pprint import pprint
import sys
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 10**9 + 7

N, K = rl()
H = rl()

H.sort()
H.reverse()
print(sum(H[K:]))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import deque

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

if K > len(h):
    print(0)
    exit()

h = deque(sorted(h))

for i in range(K):
    h.pop()

print(sum(h))