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,*l=map(int,open(0).read().split())
print([0,sum(sorted(l)[:n-k])][n>k])

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**7) #再帰関数の上限,10**5以上の場合python
import math
from copy import copy, deepcopy
from copy import deepcopy as dcp
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque
#deque(l), pop(), append(x), popleft(), appendleft(x)
##listでqueの代用をするとO(N)の計算量がかかってしまうので注意
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate,combinations,permutations#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone
#import fractions#古いatcoderコンテストの場合GCDなどはここからimportする
from functools import lru_cache#pypyでもうごく
#@lru_cache(maxsize = None)#maxsizeは保存するデータ数の最大値、2**nが最も高効率
from decimal import Decimal

def input(): 
    x=sys.stdin.readline()
    return x[:-1] if x[-1]=="\n" else x
def printl(li): _=print(*li, sep="\n") if li else None
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)
def matmat(A,B):
    K,N,M=len(B),len(A),len(B[0])
    return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)]
def matvec(M,v):
    N,size=len(v),len(M)
    return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)]
def T(M):
    n,m=len(M),len(M[0])
    return [[M[j][i] for j in range(n)] for i in range(m)]
def main():
    mod = 1000000007
    #w.sort(key=itemgetter(1),reversed=True)  #二個目の要素で降順並び替え

    #N = int(input())
    N, K = map(int, input().split())
    H = list(map(int, input().split())) #1行ベクトル
    #L = tuple(int(input()) for i in range(N)) #改行ベクトル
    #S = tuple(tuple(map(int, input().split())) for i in range(N)) #改行行列
    if K>=len(H):
        print(0)
        return
    if K==0:
        print(sum(H))
        return 
    H.sort()
    H=H[:-K]
    print(sum(H))




if __name__ == "__main__":
    main()

Submission status: Accepted

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

print(sum(H[K:]))

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
h=list(map(int,input().split()))
if k>=n:
    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 = (int(a) for a in 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())
print(sum(sorted(map(int,input().split()),reverse=True)[K:]))

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
H = list(map(int, input().split()))
if K>=N:
    print(0)
elif K==0:
    print(sum(H))
else:
    H.sort()
    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)
X = sum(H)
if X == 0:
  print(sum(H))
elif N >= K:
  list = H[N-K:N+1]
  print(sum(H)-sum(list))
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)
    exit()
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(reverse=True)

H=H[K:]

H_cumsum=[0]
H_sum_=0
for n in range(len(H)):
    H_sum_=H_sum_+H[n]
    H_cumsum.append(H_sum_)
print(H_sum_)

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

Submission status: Accepted

Solution code:
#153
def main():
    N, K = map(int,input().split())
    H = list(map(int,input().split()))
    H.sort()
    H.reverse()
    H = H[K:]
    cost = 0
    for i in H:
        cost+=i
    print(cost)
main()

Submission status: Accepted

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

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

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

H.sort()
H.reverse()

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from sys import exit

n, k = map(int, input().split())
if n <= k:
  print(0)
  exit()

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

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

Submission status: Accepted

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

print(sum(sorted(arr)[::-1][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:
    print(sum(H[:N-K]))

Submission status: Accepted

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

Submission status: Accepted

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

if K >= N:
    print(0)

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

s_h = sorted(h, reverse=True)

a_h = s_h[k:]

ans = sum(a_h)

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,K=map(int,input().split())
H=sorted(list(map(int,input().split())))
print(sum(H[0:len(H)-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)
if K>=N:
    print(0)
    exit()

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

if(K >= N):
  ans = 0
else:
  while(i<K):
    l[N-i-1] = 0
    i += 1
  ans = sum(l)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

h.sort()

if n<=k: print(0)
else:
    for i in range(k):
        h.pop(-1)

    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:
def resolve():
    N, K = map(int, input().split())
    H = list(map(int, input().split()))
    ans = sorted(H)
    if K <= 0:
        print(sum(H))
    elif N < K:
        print("0")
    else:
        print(sum(ans[:K*-1]))
resolve()

Submission status: Accepted

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

n,k = map(int,input().split())
L=list(map(int,input().split()))
L.sort()
val = n-k
if k>=n:
    val=0
L=L[0:val]
print(sum(L))

Submission status: Accepted

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

H = H[K:]

print(sum(H))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8
import sys
# from operator import itemgetter
sysread = sys.stdin.readline
read = sys.stdin.read
sys.setrecursionlimit(10 ** 7)
#from heapq import heappop, heappush
#from collections import defaultdict
# import math
# from itertools import product, accumulate, combinations, product
# import bisect# lower_bound etc
#import numpy as np
# from copy import deepcopy
#from collections import deque
#import numba

def run():
    N, K = map(int, input().split())
    H = list(map(int, sysread().split()))
    H = sorted(H)
    if N <= K:
        print(0)
        return None
    elif K == 0:
        print(sum(H))
        return None
    else:
        print(sum(H[:-K]))

if __name__ == "__main__":
    run()

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

Submission status: Accepted

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

if k >= n:
    mini = 0
else:
    h.sort(reverse=True)
    mini = 0
    for i in range(k, n):
        mini += h[i]
print(mini)

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

Submission status: Accepted

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

H_list = list(reversed(sorted(H_list)))

H_list = H_list[K:]

print(sum(H_list))

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys
input = lambda: sys.stdin.readline().rstrip()

def main():
    n, k = map(int, input().split())
    h = sorted([int(i) for i in input().split()])
    for _ in range(k):
        h.pop()
        if h == []:
            print(0)
            return
    print(sum(h))

if __name__ == '__main__':
    main()

Submission status: Accepted

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

S.sort()
S.reverse()


goukei=0
pos=0

while pos<K:
    S[pos]=0
    pos+=1
    if pos>=N:
        break

for i in range(N):
    goukei+=S[i]
print(goukei)

Submission status: Accepted

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

Submission status: Accepted

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

l=sorted(h,reverse=True)

ans=0
for i in range(k,n):
  ans=ans+l[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)
if k >= n:
  print(0)
else:
  del H[0:k]
  print(sum(H))

Submission status: Accepted

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

if N < K:
    print(0)
else:
    H.sort()
    for i in range(1,K+1):
        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()

cnt = 0

for i in range(k):
  h.pop()
  if not h:
    break
  
for i in h:
  cnt += i

print(cnt)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
A = list(map(int, input().split()))
# 強い順に並べるから降順
A.sort(reverse=True)
print(sum(A[K:]))

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
n, k, *h = map(int, open(0).read().split())
a = 0
h.sort()
for i in range(n-k):
    a += h[i]
print(a)

Submission status: Accepted

Solution code:
array = []

for i in range(2):
    val = input().split()
    array.append(val)

n = int(array[0][0])
k = int(array[0][1])
h = sorted([int(s) for s in array[1]], reverse=True)

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
N,M=map(int,input().split())
L=list(map(int,input().split()))
if N<=M:
  print(0)
  sys.exit()
L=sorted(L,reverse=True)
print(sum(L[M:N]))

Submission status: Accepted

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

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

Hs = sorted(Hs)
print(sum(Hs[:max(N-K, 0)]))

Submission status: Accepted

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

HP.sort(reverse=True)
if n <= k:
  print(0)
else:
  print(sum(HP[k:]))

Submission status: Accepted

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

Submission status: Accepted

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

if len(monsters) <= K:
    print('0')
else:
    monsters.sort(reverse=True)
    print(sum(monsters[K:]))

Submission status: Accepted

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

def solve(N: int, K: int, H: "List[int]"):
    sum_HP = sum(H)
    H = sorted(H, reverse=True)
    if K >= N:
        print('0')
        return
    for k in range(K):
        kth_HP = H[k]
        sum_HP -= kth_HP
    if sum_HP <= 0:
        print('0')
    else:
        print(sum_HP)
    return


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

if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

S = sorted(H, reverse=True)

print(sum(S[K:]))

Submission status: Accepted

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

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

a.sort(reverse =True)

print(sum(a[k:]))

Submission status: Accepted

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

h.sort()
ans = 0

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

print(ans)

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
h=sorted(list(map(int,input().split())))
ans=0
for i in range(max(n-k,0)):
  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)
ans = 0

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

print(ans)

Submission status: Accepted

Solution code:
import heapq

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

H = list(map(lambda x:x*(-1), H))
heapq.heapify(H)

if N > K:
    for _ in range(K):
        heapq.heappop(H)

    ans = sum(H) * (-1)
else:
    ans = 0

print(ans)

Submission status: Accepted

Solution code:
N,K=map(int, input().split())
H=list(map(int,input().split()))
flag=True
if K>=len(H):
    print(0)
    flag=False

if flag:
    H.sort()
    ans=sum(H[i] for i in range(len(H)-K))
    print(ans)

Submission status: Accepted

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

n, k, *h = map(int, read().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()))
if N<=K:
    print(0)
else:
    H.sort()
    m = 0
    for i in range(N-K):
        m += H[i]
    print(m)

Submission status: Accepted

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

h.sort(reverse=True)
del h[0 : min(n, 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[k:]))

Submission status: Accepted

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

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

H.sort(reverse = True)

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

Submission status: Accepted

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

l = sorted(h)
if k >= n:
  print('0')
else:
  for _ in range(k):
    l.pop(-1)
  print(sum(l))

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
h=list(map(int,input().split()))
h.sort(reverse=True)
nokori=max((n-k),0)
if nokori==0:
  print(0)
  exit()

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

Submission status: Accepted

Solution code:


def solve(N, K, Hs):
    Hs.sort(reverse=True)
    ans = 0
    for h in Hs:
        if K > 0:
            K -= 1
        else:
            ans += h
    print(ans)


if __name__ == '__main__':
    N, K = map(int, input().split())
    Hs = [int(i) for i in input().split()]
    solve(N, K, Hs)

Submission status: Accepted

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

Submission status: Accepted

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

if len(H)<=K:
    print(0)
else:
    H.sort()
    cnt=0
    for i in range(len(H)-K):
        cnt+=H[i]
    print(cnt)

Submission status: Accepted

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

def main():
    N, K = map(int, input().split())
    if N <= K:
        print('0')
        exit()
    else:
        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()
for k in range(K):
    if H:
        H.pop(len(H)-1)
H = sum(H)
print(H)

Submission status: Accepted

Solution code:
H,N = list(map(int,input().split(" ")))
A = list(map(int,input().split(" ")))
total = 0
A.sort(reverse=True)
del A[:N]
for i in A:
  total +=i
print(total)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

print(sum(LIST[k:]))

Submission status: Accepted

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

h.sort(reverse=True)

h = h[k:]

print(sum(h))

Submission status: Accepted

Solution code:
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()))
if k>=n:
    print(0)
else:
    s_h=sorted(h)[::-1]
    print(sum(s_h[k:]))

Submission status: Accepted

Solution code:
import sys
from collections import defaultdict
readline = sys.stdin.buffer.readline


def geta(fn=lambda s: s.decode()):
    return map(fn, readline().split())


def gete(fn=lambda s: s.decode()):
    return fn(readline().rstrip())


# sys.setrecursionlimit(10**5)


def main():
    n, k = geta(int)
    h = list(geta(int))

    h.sort()

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


if __name__ == "__main__":
    main()

Submission status: Accepted

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


if len(H) <= K:
    print('0')
else:
    HA = sorted(H)
    HA = HA[:len(H) - K]
    print(str(sum(HA)))

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
#n体のモンスター, k回の必殺技を使える
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 K >= N:
    print(0)
elif K == 0:
    print(sum(H))
else:
    H.sort()
    print(sum(H[:N - K]))

Submission status: Accepted

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

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines


def main():
    N, K = map(int, readline().split())
    Hs = list(map(int, readline().split()))
    Hs.sort(reverse=True)
    print(sum(Hs[K:]))


if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

main()

Submission status: Accepted

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

    hs = sorted(hs)[::-1]
    ans = sum(hs[k:])
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

#n,k = 3,3
#h = [1000000000,1000000000,1000000000]

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
input = lambda: sys.stdin.readline().strip()

def solve(N: int, K: int, H: "List[int]"):
    H.sort()
    print(sum(H[i] for i in range(N - K)) if K < N else 0)

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    H = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, K, H)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

def solve():
    global n, k, h
    if n <= k:
        return 0
    s = sum(h)
    h = sorted(h, reverse=True)
    for i in range(k):
        s -= h[i]
    return s

print(solve())

Submission status: Accepted

Solution code:
import math
import string
import collections
from collections import Counter


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


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]
n, k = map(int, input().split())
h = readints()
h_sort = sorted(h, reverse=True)
# print(h_sort)
# print(h_sort[k:])
h_sort2 = h_sort[k:]
if h_sort2 == []:
    print(0)
    exit()
ans = 0
for i in range(len(h_sort2)):
    ans += h_sort2[i]
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
H, 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()))
J = sorted(H)
if N <= K:
    print(0)
    exit()
P = J[:(N-K)]
print(sum(P))

Submission status: Accepted

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

Submission status: Accepted

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

sort = sorted(H, reverse = True)
ans = 0
for i in range(N):
    if i+1 > K:
        ans += sort[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)
if k < n:
    print(sum(h[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)
Q=sum(H[0:K])

print(sum(H)-Q)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:

def main():
    N,K  = map(int, input().split()) 
    H = list(map(int, input().split())) 
    H.sort()
    if K>=len(H):
        print(0)
    else:
        print(sum(H[0:len(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)
elif K == 0:
  print(sum(H))
else:
  H.sort()
  H_hissatsued = H[:-K]
  #print(H_hissatsued)
  print(sum(H_hissatsued))

Submission status: Accepted

Solution code:
import sys
N,K=map(int,input().split())
H=list(map(int,input().split()))
H.sort()
for _ in range(K):
    H.pop(-1)
    if len(H)==0:
        print(0)
        sys.exit()
print(sum(H))

Submission status: Accepted

Solution code:
# import sys
# import math
# import itertools
# from collections import deque
# from collections import defaultdict
# import heapq
# import copy
# import bisect
# import numpy as np
# from scipy.special import comb

# def my_input(): return sys.stdin.readline().rstrip()
# sys.setrecursionlimit(100000)
# INF = 1001001001001
# MOD = 1000000007

def main():

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

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

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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

H = list(input().split())
H = sorted([int(H[i]) for i in range(N)], reverse=True)

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

Submission status: Accepted

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