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:
class Main:
    s = list(map(int, input().split()))
    n = s[0]
    k = s[1]
    sum = 0
    kSum = 0
    list = [int(i) for i in input().split()]
    newList = sorted(list, reverse=True)
    list[:k]
    for num in newList:
        sum += num
    for kNum in newList[:k]:
        kSum += kNum
    print(sum-kSum)

Submission status: Accepted

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

atack_number = len(enemies) - k

if atack_number <= 0:
    print(0)
else:
    #敵を体力少ない順に並び替え
    enemies.sort()
    atack_select = enemies[:atack_number]
    print(sum(atack_select))

Submission status: Accepted

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

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
h=list(map(int,input().split()))
h.sort(reverse=True)
i=0
new_h=[]
if n<=k:
  print(0)
else:
  for item in h:
    i=i+1
    if i>k:
      new_h.append(item)
  print(sum(new_h))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/python3
n,k=map(int,input().split())
h=map(int,input().split())
print(sum(sorted(h)[:-k if k else n]))

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
import collections
import copy
import heapq
from collections import defaultdict
from heapq import heappop, heappush
import itertools
input = sys.stdin.readline

##### リストの 二分木検索 #####
# bisect_left(lists, 3)
# bisect_right(lists, 3)

##### プライオリティキュー #####
# heapq.heapify(a) #リストaのheap化
# heapq.heappush(a,x) #heap化されたリストaに要素xを追加
# heapq.heappop(a) #heap化されたリストaから最小値を削除＆その最小値を出力

# heapq.heappush(a, -x) #最大値を取り出す時は、pushする時にマイナスにして入れよう
# heapq.heappop(a) * (-1) #取り出す時は、-1を掛けて取り出すこと

##### タプルリストのソート #####
# sorted(ans) #(a, b) -> 1st : aの昇順, 2nd : bの昇順
# sorted(SP, key=lambda x:(x[0],-x[1])) #(a, b) -> 1st : aの昇順, 2nd : bの降順
# sorted(SP, key=lambda x:(-x[0],x[1])) #(a, b) -> 1st : aの降順, 2nd : bの昇順
# sorted(SP, key=lambda x:(-x[0],-x[1])) #(a, b) -> 1st : aの降順, 2nd : bの降順

# sorted(SP, key=lambda x:(x[1])) #(a, b) -> 1st : bの昇順
# sorted(SP, key=lambda x:(-x[1])) #(a, b) -> 1st : bの降順

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))

def main():
	N,K = inputMap()
	H = inputList()
 
	H.sort()
	H = H[::-1]
 
	ans = 0
	for i,vol in enumerate(H):
		if K > 0:
			K -= 1
			#print(K)
			continue
		ans += vol
 
	print(ans)



if __name__ == "__main__":
	main()

Submission status: Accepted

Solution code:
from itertools import permutations, combinations

nums = input().split()
As = input().split()
H = nums[0]
N = nums[1]
A = []


N =int(N)

As = list(map(int, As))
As = sorted(As , reverse=True)

if N != 0:
    del As[:N]

print(sum(As))

Submission status: Accepted

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

Submission status: Accepted

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

H_sorted = sorted(H, reverse=True)

print(sum(H_sorted[K:]))

Submission status: Accepted

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

if K != 0:
  HP_killed = HP[:-K]
  print(sum(HP_killed))
else:
  HP_killed = HP
  print(sum(HP_killed))

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
h = [int(x) for x in input().split()]
h = sorted(h, reverse=True)
if k < n:
    ans = sum(h[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()
if K == 0:
    pass
elif K > N:
    H.clear()
else:
    H = H[:-K]
print(sum(H))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import os
import sys
import heapq

def main():
    H , K = map(int , input().split())
    n_list = [s for s in input().split()]
    n_list = list(map(int,n_list))
    #print (n_list)
    #c = sum(int(i) for i in list)
    list_small = []
    new_list = []
    if K >= len(n_list) :
        print (str(0))
    elif K == 0 :
        c = sum(int(i) for i in n_list)
        print (str(c))
    else :
        list_small = heapq.nlargest(K,n_list)
        list_small = list(map(int,list_small))
        #print (list_small)
        #new_list = list(set(n_list)-set(list_small))
        #new_list = list_difference(n_list, list_small)
        #print (list_small)
        #print (new_list)
        c = sum(int(i) for i in n_list)
        d = sum(int(i) for i in list_small)
        print (str(c-d))
    #print (str(X))

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math

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

enemys.sort(reverse=True)
count = 0
for e in enemys:
  if(k > 0):
    k -= 1
  else:
    count += e

print(count)

Submission status: Accepted

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


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

    print(count)

Submission status: Accepted

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

n.sort()
for i in range(B):
  if n:
    n.pop()
print(sum(n))

Submission status: Accepted

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

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

use_clipboard=False
bbn=1000000007
	
#+++++

		
def main():
	n,k = map(int, input().split())
	hl=list(map(int, input().split()))
	hl.sort()
	#pa(hl)
	if k > 0:
		ret = sum(hl[:-k])
	else:
		ret=sum(hl)
	print(ret)
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
class input_clipboard:
	def __init__(self,s):
		self.input_l=s.splitlines()
		self.ii=0
		
	def input(self):
		ret = self.input_l[self.ii]
		self.ii+=1
		return ret

if __name__ == "__main__":
	if sys.platform =='ios':
		if use_clipboard:
			import clipboard
			input_text=clipboard.get()
			ic=input_clipboard(input_text)
			input = lambda : ic.input()
		else:
			sys.stdin=open('inputFile.txt')
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Submission status: Accepted

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

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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n,k,*h=map(int,open(0).read().split())
h=sorted(h)[::-1]
for i in range(min(k,n)):h[i]=0
print(sum(h))

Submission status: Accepted

Solution code:
N, K = 0, -1
while (N < 1 or N > 2 * 10**5) and (K < 0 or K > 2 * 10**5):
  N, K = input().split()
  N, K = int(N), int(K)

flag = False
while flag == False:
  H = input().split()
  flag = (sum([((int(i) >= 1) and (int(i) <= 10**9)) for i in H]) == len(H))

H = [int(s) for s in H]
H.sort(reverse=True)
attack = []
for i,v in enumerate(H):
  if(i >= K):
    attack.append(v)
print(sum(attack))

Submission status: Accepted

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

#cast
for i in range(N):
  H[i] = int(H[i])

#sort
H.sort(reverse = True)

#calculate
ans = 0

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

print(ans)

Submission status: Accepted

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

if K >= N:
  print(0)
 
elif K == 0:
  print(sum(H))

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

Submission status: Accepted

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

h.sort()

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

Submission status: Accepted

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

s.sort(reverse=True)

if K>=len(s):
  for A in range(len(s)):
    s[A]=0

else:
  for A in range(K):
    s[A]=0



for A in s:
  sum+=A
 
print(sum)

Submission status: Accepted

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

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

Ar = Input2


if K > H:
  K = H

Ar.sort(reverse=True)
del Ar[:K]

print(sum(Ar))

Submission status: Accepted

Solution code:
n, k = map(int , input().split())
h = list(map(int, input().split()))
count = 0
MOD = 1000000007
h.sort()
try:
    if(k != 0):
        del h[-k]
    for i in range(n - k):
        count += h[i]%MOD
    print(count)
except IndexError:
    count = 0
    print(count)

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:
    sorted_h = sorted(H, reverse=True)
    print(sum(sorted_h[K:]))

Submission status: Accepted

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

Submission status: Accepted

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

if K == 0:
    print(sum(H_))
else:
    print(sum(sorted(H_)[:-K]))

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
h = list(map(int, input().split()))
 
h_ = sorted(h)
 
for i in range(k):
    if len(h_) > 0:
        h_.pop()
    
s = [0]*(len(h_)+1)
for j in range(len(h_)):
    s[j+1] = s[j] + h_[j]

print(s[-1])

Submission status: Accepted

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

if(int(n)<=int(k)):
    print(0)
elif(int(k)==0):
    print(sum(mon))
else:    
    mon.sort(reverse=True)
    for i in range(0,int(k)):
        mon[i] = 0
        
    print(sum(mon))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, K = [int(i) for i in input().rstrip().split(' ')]
H = [int(i) for i in input().rstrip().split(' ')]
H.sort(reverse=True)
if len(H) <= K:print(0)
else:
    lst = [h for k, h in enumerate(H) if k >= K]
    print(sum(lst))

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
hps=list(map(int,input().split()))
hps.sort()
if k>n:
  print(0)
elif k==n:
  print(0)
else:
  ans=0
  for i in range(k):
    hps.pop()
  ans+=sum(hps)
  print(ans)

Submission status: Accepted

Solution code:
H,K=map(int, input().split())
V = list(input().split())
V = [int(x) for x in V]
V.sort(reverse = True)
if K > H:
    K = H
if H <= K:
    print(0)
else:
    print(sum(V[K:H]))

Submission status: Accepted

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

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

sorted_h = sorted(list_h, reverse=True)

del sorted_h[:k]

print(sum(sorted_h))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
Hlist = list(map(int, input().split()))
Hlist.sort(reverse=True)
if K == 0:
  print(sum(Hlist))
else:
  Hlist[0:K] = []
  print(sum(Hlist))
'''
elif K == 1:
  del Hlist[0]
  print(sum(Hlist))
elif K == 2:
  del Hlist[0]
  del Hlist[0]
  print(sum(Hlist))
else:
  del Hlist[0:K-1]
  print(sum(Hlist))
'''

Submission status: Accepted

Solution code:
hs= input().split()
h = int(hs[0])
s = int(hs[1])
my_list = input().split()
total = 0
for i in range(len(my_list)):
  my_list[i] = int(my_list[i])
my_list.sort(reverse = True)
for j in range(s, len(my_list)):
  total = total + my_list[j]
print(total)

Submission status: Accepted

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

Submission status: Accepted

Solution code:

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

H.sort(reverse=True)

ans = 0
ans += sum(H[K:])

print(ans)

Submission status: Accepted

Solution code:
import numpy as np

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

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

Submission status: Accepted

Solution code:
"""
Fennec should do special move on the K monsters with largest health.
then the other monsters take H turns to kill.
so total turns is H[i] for i in low health monsters
"""

def calc_num_turns(K, H):
  H.sort(reverse=True)
  total_turns = sum(H[K:])
  return total_turns


if __name__ == "__main__":
  K = int(input().split()[1])
  H = list(map(int, input().split()))
  print(calc_num_turns(K, H))

Submission status: Accepted

Solution code:

N, K = map(int, input().split())
Hs = map(int,input().split())
print(sum(sorted(Hs, reverse=True)[K::]))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

print(sum(h[min(n,k):]))

Submission status: Accepted

Solution code:
h,k=map(int,input().split())
H = sorted(list(map(int,input().split())))[::-1]

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

Submission status: Accepted

Solution code:
arr = input().split(" ")
H = int(arr[0])
K = int(arr[1])

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

if(K == 0):
    print(sum(HPs))
else:
    print(sum(HPs[K:]))

Submission status: Accepted

Solution code:
h, n = [int(x) for x in input().split()]
listk = [int(x) for x in input().split()]
listk.sort()
if n <= h:
    for i in range(0,n):
        listk.pop()
else:
    for i in range(0,h):
        listk.pop()
print(sum(listk))

Submission status: Accepted

Solution code:
import numpy as np
n, k = [int(i) for i in input().split()]
h = np.array(sorted([int(i) for i in input().split()], reverse=True))
print(sum(h[k:]))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import deque

N, K = map(int,input().split())
monsters = list(map(int, input().split()))
monsters.sort(reverse=True)
monsters = deque(monsters)
count = 0

while K > count:
  count += 1
  try:
    monsters.popleft()
  except IndexError:
    pass

print(sum(monsters))

Submission status: Accepted

Solution code:
N,K=map(int,input().split())
H=list(map(int,input().split()))
t=sorted(H)
n=list()
for i in range(N-K):
    n.append(t[i])
print(sum(n))

Submission status: Accepted

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

Submission status: Accepted

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

cnt = 0
if K >= N:
    cnt = 0
elif 1 <= K < N:
    H_down = sorted(H, reverse = True)
    cnt = sum(H_down[K:])

elif K == 0:
    cnt = sum(H)

print(cnt)

Submission status: Accepted

Solution code:
import heapq
list1 = input().split(' ')
list2 = input().split(' ')
list2 =  [int(s) for s in list2]

special = int(list1[1])
enemy = int(list1[0])

list = sorted(list2, reverse=True)
a = heapq.nsmallest(enemy-special, list)

if special >= enemy:
  print(0)
else:
  NN = 0
  for N in a:
    NN += N
  print(NN)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
NK = input().split()
N,K = int(NK[0]),int(NK[1])
H = list(map(int,input().split()))
if K != 0 and len(H) < K:
    print(0)
    exit()
H.sort()
for i in range(K):
    H.pop(-1)
print(sum(H))

def input():
    return sys.stdin.readline()[:-1]

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**6)

# 入力
N,K =map(int,input().split())
InpList = list(map(int,input().split()))

result=0
i=0

# 必殺技の使用回数が1以上の場合、体力の多い敵から使っていく
InpList=sorted(InpList)[::-1]

if K>N:
    result=0
else:
    if K>0:
        for i in range(K):
            InpList[i]=0
    result=sum(InpList)

print(result)

Submission status: Accepted

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

H_sorted = sorted(H, reverse=True)

print( sum( H_sorted[min(K, len(H_sorted)):] ))

Submission status: Accepted

Solution code:
import math
N,K = map(int,(input().split()))
#print(N,K)
L = list(map(int,(input().split())))
L.sort()
#print(L)
num = N-K
if(num < 0):
    num = 0
L = L[0:num]
#print(L)
print(sum(L))

Submission status: Accepted

Solution code:


def main():
    N, K = map(int, input().split())
    H = list(map(int, input().split()))
    H = sorted(H, reverse=True)
    sum_H = 0
    for h in H:
        if K > 0:
            K -= 1
            continue
        sum_H += h
    print(sum_H)

if __name__ == "__main__":
    main()

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import numpy as np

N,K =(int(x) for x in input().split())
list1 = np.array([int(s) for s in input().split()])


list2=np.sort(list1)

i=0
sum=0
while i<=N-K-1:
  sum=sum+list2[i]
  i=i+1

print(sum)

Submission status: Accepted

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

Submission status: Accepted

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

for x in a:
    if k > 0:
        k -= 1
    else:
        ans += x

print(ans)

Submission status: Accepted

Solution code:
# ABC 153 C

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

H.sort()

for _ in range(k):
    if len(H) != 0:
        H.pop()
    else:
        break

print(sum(H))

Submission status: Accepted

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

a = sorted(a, reverse=True)

def sum_ary(ary):
  total = 0
  for a in ary:
    total += a
  return total

if n >= len(a):
  print(0)
  exit()
del a[:n]
print(sum_ary(a))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, K = input().split()
N = int(N)
K = int(K)
H = input()
H = [int(i) for i in H.split()]
H.sort()
while (K > 0 and len(H) != 0):
  del H[-1]
  K -=1
print(sum(H))

Submission status: Accepted

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

if len(HListSorted) <= K:
    print('0')
else:
    HList = HListSorted[K:]
    print(sum(HList))

Submission status: Accepted

Solution code:
NK=input().split()
N=int(NK[0])
K=int(NK[1])
Hlis=list(map(int,input().split()))
ans=0

if K>=N:
    print(0)
else:
    Hlis.sort()
    for i in range(N-K):
        ans+=Hlis[i]
    print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, K = map(int, input().lower().split())
H = []
total = 0
input_string = input()
H = input_string.split()
H = list(map(int, H))

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

print(sum(H))

Submission status: Accepted

Solution code:
K, N = list(map(int, input().split()))
h = list(map(int, input().split()))
#倒す数
a = K-N
if 0>=a:
  print(0)
else:
  print(sum(sorted(h)[:a]))

Submission status: Accepted

Solution code:
from sys import stdin


def main(inp1, inp2):
    n, k = [int(i) for i in inp1.split(sep=' ')]
    h_list = sorted([int(i) for i in inp2.split(sep=' ')])

    num_enemy = n
    enable_special = k

    if enable_special >= num_enemy:
        return 0
    elif enable_special == 0:
        return sum(h_list)
    else:
        return sum(h_list[:-enable_special])


if __name__ == '__main__':
    input1 = stdin.readline().rstrip()
    input2 = stdin.readline().rstrip()
    ret = main(input1, input2)
    print(ret)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
in_len = input().split(" ")

in_n = int(in_len[0])
in_k = int(in_len[1])
in_h = input().split(" ")
out = 0

sort_h = sorted(in_h, reverse=True, key=int)
i = in_k

while i < in_n:
  out += int(sort_h[i])
  i += 1

print(out)

Submission status: Accepted

Solution code:
N, K = map(int, input().lower().split())
H = []
total = 0
input_string = input()
H = input_string.split()
H = list(map(int, H))

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

print(sum(H))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
monster, skill = map(int,input().split())

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

monster_hp.sort()

attack_count = 0

while(skill>0):
    skill -= 1
    if len(monster_hp) > 0:    
        monster_hp.pop(-1)
    

for hp in monster_hp:
    attack_count += hp

print(attack_count)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

if K >= N:
    print(0)
elif K == 0:
    answer = np.sum(H)
    print(answer)
else:
    ind = np.argpartition(H, -K)[-K:]
    top_k = H[ind]
    answer = np.sum(H) - np.sum(top_k)
    print(answer)

Submission status: Accepted

Solution code:
NK = list(map(int, input().split()))
H = list(map(int, input().split()))
H.sort(reverse= False)
Hlen = len(H)
N = NK[0]
i = NK[1]
X = 0
for i in range(N - i):
	X += H[i]
print(X)

Submission status: Accepted

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

h.sort()
# 必殺技の回数だけ体力の高い敵から倒す
# 最後に残ったやつが0になる攻撃回数を出力する
for i in range(k):
    h.pop()
    if len(h) == 0:
        break
print(0 if len(h) == 0 else sum(h))

Submission status: Accepted

Solution code:
s = input().split()  # s[0]は敵の数, s[1]は必殺技が使える数
s2 = list(map(int, input().split()))  # 敵の体力
s2_n = sorted(s2, reverse=True)[int(s[1]):]
# print(sum(s2))
print(sum(s2_n))


#
# if sum(s2) >= int(s[0]):
#     print("Yes")
# else:
#     print("No")

Submission status: Accepted

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

H.sort(reverse=True)

if N <= K:
    ans = 0
else:
    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 = [int(h_str) for h_str 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(reverse=True)
del H[:K]
print(sum(H))

Submission status: Accepted

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

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:
    for n in range(K):
        H.pop()

    sumH = sum(H)

    print(sumH)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
  N, K = map(int, input().split())
  
  H = sorted(list(map(int, input().split())), reverse=True)
 
  n = sum(H)
  
  if K == 0:
    print(n)
  elif N > K:
    for i in range(K):
      n -= H[i]
    print(n)
  else:
    print(0)
    
  return 0
 
if __name__ == "__main__":
  main()

Submission status: Accepted

Solution code:
m,a=(int(x) for x in input().split())
lm = list(map(int, input().split()))
lm.sort(reverse=True)
#print(lm)
del lm[0:a]
#print(lm)
print(sum(lm))

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().rstrip().split())
Hs = [int(x) for x in input().rstrip().split()]

if K == 0:
    print(sum(Hs))
else:
    print(sum(sorted(Hs)[:-K]))

Submission status: Accepted

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

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

# print(H)
# print(H)

if N <= K:
    print(0)
else:
    H = sorted(H, reverse=True)
    # for _ in range(K):
    #     if len(H) == 0:
    #         break
    #     H.pop(0)
    
    # print(H)
    
    result = 0
    for i in range(K, N):
        result += H[i]

    print(result)

Submission status: Accepted

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

ld[0:K] = []
print(sum(ld))

Submission status: Accepted

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

T = N-K
H.sort()

ans = 0

for n in range(T):
    ans += H[n]

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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