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

    H.sort(reverse=True)
    if K != 0 :
        h = H[K:]
        print(sum(h))
    else:
        print(sum(H))
resolve()

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

for _ in range(min(k, len(h_list))):
    h_list.pop()
for h in h_list:
    sum += h
print(sum)

Submission status: Accepted

Solution code:
import sys
n, k = [int(i) for i in sys.stdin.readline().split()]
k = min(k, n)
h_ls = [int(i) for i in sys.stdin.readline().split()]
h_ls.sort()
print(sum(h_ls[:n-k]))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
Input = input().split(" ")
N = int(Input[0])
K = int(Input[1])
Input2 = input().split(" ")
enemys = sorted([int(A) for A in Input2], reverse=True)
if N<=K:
  print(0)
else:
  print(sum(enemys[K:]))

Submission status: Accepted

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


if N<=K:
    print(0)
else:
    ListH.sort()
    sum=0
    for i in range(N-K):
        sum+=ListH[i]

    print(sum)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from bisect import bisect

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, K = MAP()
H = LIST()

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

Submission status: Accepted

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from bisect import bisect

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, K = MAP()
H = LIST()

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

Submission status: Accepted

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

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

Submission status: Accepted

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

# スペース区切りの整数の入力
n, k = map(int, input().split())

# n個の要素の入力
l = list(map(int, input().split()))
l.sort()
l.reverse()

# 出力
if n <= k:
    print("0")
else:
    print("{}".format(sum(l[k:])))

Submission status: Accepted

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

list_H.sort()

while K :
    if list_H :
        list_H.pop()
    K -= 1

print(sum(list_H))

Submission status: Accepted

Solution code:
# 5

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

Submission status: Accepted

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

Submission status: Accepted

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

atk = 0

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

Hps.sort()

bsp = []
for sp in reversed(Hps):
    if K > 0:
        K -= 1
    else:
        bsp.append(sp)

for x in bsp:    
    atk += x

print(atk)

Submission status: Accepted

Solution code:
"""
author : halo2halo
date : 4, Feb, 2020
"""

import sys

# import itertools
# import math

# import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
INF = 10 ** 9

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

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

Submission status: Accepted

Solution code:
def main():
    n,k=map(int,input().split())
    H=list(map(int,input().split()))
    if n<=k:
        return 0
    H.sort(reverse=True)
    return sum(H[k:])
    
if __name__=='__main__':
    print(main())

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

print(sum(H))

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
NK = input().split()
N = int(NK[0])
K = int(NK[1])
Hs = input().split()
Hs = [int(h) for h in Hs]

import numpy as np
Hs = np.array(Hs)
Hs = np.sort(Hs, kind="quick_sort")
if K > 0:
  s = np.sum(Hs[0:-K]) if N > K else 0
else:
  s = np.sum(Hs)
print(s)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from sys import stdin, stdout

def main():
	N, K = (int(x) for x in stdin.readline().split())
	health = [int(x) for x in stdin.readline().split()]
	health.sort()
	for _ in range(min(len(health), K)):
		health.pop()
	stdout.write(str(sum(health)))

if __name__ == "__main__":
	main()

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

print(sum(h))

Submission status: Accepted

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

def merge_sort(arr):
    if len(arr) <= 1:
        return arr

    mid = len(arr) // 2
    # ここで分割を行う
    left = arr[:mid]
    right = arr[mid:]

    # 再帰的に分割を行う
    left = merge_sort(left)
    right = merge_sort(right)

    # returnが返ってきたら、結合を行い、結合したものを次に渡す
    return merge(left, right)


def merge(left, right):
    merged = []
    l_i, r_i = 0, 0

    # ソート済み配列をマージするため、それぞれ左から見ていくだけで良い
    while l_i < len(left) and r_i < len(right):
        # ここで=をつけることで安定性を保っている
        if left[l_i] <= right[r_i]:
            merged.append(left[l_i])
            l_i += 1
        else:
            merged.append(right[r_i])
            r_i += 1

    # 上のwhile文のどちらかがFalseになった場合終了するため、あまりをextendする
    if l_i < len(left):
        merged.extend(left[l_i:])
    if r_i < len(right):
        merged.extend(right[r_i:])
    return merged

ll = merge_sort(ls)
if n <= k:
    print(0)
else:
    print(sum(ll[:n-k]))

Submission status: Accepted

Solution code:
li_a = input().split()

li_b = input().split()

li_a = [int(i) for i in li_a]
i = 0
li_b = [int(i) for i in li_b]

li_c = sorted(li_b,reverse=True)

for j in range(li_a[1]):
    if j == len(li_b):
        break
    li_c[j] = 0

print(sum(li_c))

Submission status: Accepted

Solution code:
import numpy as np

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

H = np.array(H)
print(H[K:].sum())

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
h,k = map(int,input().split())
a = list(map(int,input().split()))
if k>h or k==h:
    att = 0
else:
    a2 = sorted(a)
    sum = 0
    for i in range(-1,-(k+1),-1):
        sum = sum + a2[i]
    count = 0
    for j in range(0,h,1):
        count = count+a[j]
    lastSum = count-sum
    att = lastSum//1
print(att)

Submission status: Accepted

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

H.sort(reverse=True)

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

Submission status: Accepted

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

total = 0
for i in h:
    if k != 0:
        k-=1
    else:
        total+=i

print(total)

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#ArCorder FennecvsMonster
def main():
	N, K = map(int, input().split())
	H = [int(_) for _ in input().split()]
	H.sort(reverse=True)
	
	if K>=N:
		print('0')
	else:
		print(sum(H[K:]))
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 = sorted(h)
  print(sum(h[:n-k]))

Submission status: Accepted

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

a.sort()
m = max(n - k, 0)

sum = 0
for i in range(m):
  sum += a[i]

print(sum)

Submission status: Accepted

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

    ans = 0
    if N>K : ans = sum(Hi[K:])
    
    print(ans)
    return

if __name__=="__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
# s = sys.stdin.readlines()
inputs = sys.stdin.readline()
H = sys.stdin.readline()
inputs = inputs.split()
N, K = int(inputs[0]), int(inputs[1])
H = [int(h) for h in H.split()]
H = sorted(H)[::-1]

count = 0
for h in H[K:]:
    count += h

print(count)

Submission status: Accepted

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

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

else:
	h.sort(reverse = True)

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

	print(sum(h))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from sys import stdin

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

H = sorted(H, reverse=True)

print(sum(H[K:]))

Submission status: Accepted

Solution code:
import numpy as np

def resolve():
    n, k = map(int, input().split())
    h = list(map(int, input().split()))

    h = np.sort(h)
    h = h[::-1]

    print(np.sum(h[k:]))

resolve()

Submission status: Accepted

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

if K > N:
  	print(0)
else:
	H.sort()

	H = H[0 : N - K]

	for val in H:
  		sum = sum + val
  
	print(sum)

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

print(sum(h[k:]))

Submission status: Accepted

Solution code:
def solve(n, k, H):
    return sum(sorted(H)[:n - min(k, n)])

_n, _k = map(int, input().split())
_H = map(int, input().split())
print(solve(_n, _k, _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 len(h)>0:
        h.pop()
print(sum(h))

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
n, k = map(int, input().split())
h = list(map(int, input().split()))
list.sort(h, reverse=True)
print(sum(h[k:]))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
data1=input().split()
data2=[int(x) for x in input().split()]
Nu=int(data1[0])
Kill=int(data1[1])
data2.sort()
if Nu>Kill:
	data3=data2[0:Nu-Kill]
else:
  data3=[]
print(sum(data3))

Submission status: Accepted

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

Submission status: Accepted

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

sum_hp = 0


hp.sort()


for i in range(k):
    if(len(hp)> 0):
        hp.pop()



for j in hp:
    sum_hp = sum_hp + int(j)

print(str(sum_hp))

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

for i in range(K):
  if len(H) == 0:
    break
  H.pop()

print(sum(H))

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from math import ceil
from sys import stdin
n,k = map(int,stdin.readline().split())
h = sorted(list(map(int,stdin.readline().split())))
ans = 0
for i in range(0,len(h)-k): ans += h[i]
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:

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

h=sorted(H)

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
N, K = map(int, input().split(" "))
print(sum(sorted(map(int, input().split(" ")), reverse=True)[K:]))

Submission status: Accepted

Solution code:
a,b = input().split()
a = int(a)
b = int(b)
sum = 0
c = list(map(int,input().split()))
c.sort(reverse=True)
del c[0:b]
for i in range(len(c)):
  sum +=c[i]
print(sum)

Submission status: Accepted

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

monsters.sort()
if n - k > 0:
    should_attack = monsters[:n-k]
    print(sum(should_attack))
else:
    print(0)

Submission status: Accepted

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

    # time O(N log(N))
    sorted_h_list = sorted(h_list, reverse=True)
    attack_list = sorted_h_list[k:]

    ans = sum(attack_list)
    print(ans)


main()

Submission status: Accepted

Solution code:
import numpy as np
#入力
N, K = map(int, input().split())
li = list(map(int,input().split()))
list.sort(li, reverse = True)

#出力
a = list(np.zeros(K))
if N - K>=0:
    b = list(np.ones(N-K))
    a.extend(b)
else:
    a = list(np.zeros(N))

print(int(np.dot(a, li)))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
H = sorted(list(map(int, input().split())), reverse=True)#reverse=Trueは逆順
# print(H)
# print(H[k:])#後ろからkこぶんとる
print(sum(H[k:]))

Submission status: Accepted

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

if K == 0:
  print(sum(E))
  
else:
  E = sorted(E)
  for i in range(K):
    if len(E) == 0:
      break
    E.pop()
  print(sum(E))

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

print(sum(H[K:]))

Submission status: Accepted

Solution code:

if __name__ == '__main__':
    # a = int(input())
    # a, b = map(int, input().split())

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

Submission status: Accepted

Solution code:
from sys import stdin

def main():
    n,m = map(int,stdin.readline().split())
    l = list(map(int,stdin.readline().split()))
    l.sort()
    aco = 0
    for i in range(n-m):
        aco+= l[i]
    print(aco)
        
main()

Submission status: Accepted

Solution code:
from sys import stdin

def main():
    N,K = map(int,stdin.readline().split())
    arr = [int(x) for x in stdin.readline().split()]

    arr.sort()
    arr.reverse()
    res = 0
    for i in range(K,len(arr)):
        res +=arr[i]
    print(res)
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())
List = list(map(int, input().split()))


remain_monster = N - K
if remain_monster <= 0:
    monsterHP = 0

else:
    new_list = sorted(List, reverse=True)

    monsterHP = sum(new_list[-remain_monster:])

print(monsterHP)

Submission status: Accepted

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

Submission status: Accepted

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

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

print(atk)

Submission status: Accepted

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

cnt = 0
atk = 0
while True:
    for i in range(N):
        if H[i] <= 0:
            continue
        else:
            if K > 0:
                K -= 1
                H[i] = 0
                cnt += 1
            else:
                atk += H[i]
                cnt += 1

    if cnt == N:
        break

print(atk)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
enemmyCountN,killerTimeK = map(int,input().split())
enemyHp = input().split()

intEnemyHp = [int(i) for i in enemyHp]
intEnemyHp.sort()

resultEnemyCount = enemmyCountN - killerTimeK
countNormal = 0

# if killerTimeK >= enemmyCountN:
    # print(0)

# else:
for i in range(resultEnemyCount):
    countNormal += intEnemyHp[i]
print(countNormal)

Submission status: Accepted

Solution code:
enemmyCountN,killerTimeK = map(int,input().split())
enemyHp = input().split()

intEnemyHp = [int(i) for i in enemyHp]
intEnemyHp.sort()

resultEnemyCount = enemmyCountN - killerTimeK
countNormal = 0

if killerTimeK >= enemmyCountN:
    print(0)

else:
    for i in range(resultEnemyCount):
        countNormal += intEnemyHp[i]
    print(countNormal)

Submission status: Accepted

Solution code:
enemmyCountN,killerTimeK = map(int,input().split())
enemyHp = list(map(int,input().split()))

enemyHp.sort()

resultEnemyCount = enemmyCountN - killerTimeK
countNormal = 0

if killerTimeK >= enemmyCountN:
    print(0)

else:
    for i in range(resultEnemyCount):
        countNormal += enemyHp[i]
    print(countNormal)

Submission status: Accepted

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

Submission status: Accepted

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

for i in range(k,n):
  ans += num[i]
  
print(ans)

Submission status: Accepted

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

b.sort(reverse=True)
c = b[a[1]:]
cnt = 0

for i in range(len(c)):
  cnt += c[i]

print(cnt)

Submission status: Accepted

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

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

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

    # 必殺技を使える回数が敵の数より多いケースを考慮する
    K = min(N, K)

    for _ in range(K):
        heapq.heappop(q)

    print(sum(q)*-1)

if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import numpy as np

def do():
    data = np.array(input().split(" "), dtype="int64")
    life = np.array(input().split(" "), dtype="int64")
    monsters = data[0]
    smash = data[1]
    if smash == 0:
        print(np.sum(life))
    elif smash >= monsters:
        print(0)
    else:
        a = np.sort(life)[-smash]
        leftover = np.where(life < a, life, 0)
        print(np.sum(leftover))

do()

Submission status: Accepted

Solution code:
data  = [int(_) for _ in input().split()]
enemy = [int(_) for _ in input().split()]

if len(enemy) < data[1]:
    print(0)
    exit()
elif data[1] == 0:
    print(sum(enemy))
else:
    enemy.sort()
    
    print(sum(enemy[:-data[1]]))

Submission status: Accepted

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

sum = 0

H = sorted(H)

answer = 0

if N > K:
    for i in H[:N-K]:
        answer += i

print(answer)

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

Submission status: Accepted

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

n = len(A)
if k >= n:
    print(0)
    sys.exit(0)
A.sort()
print(sum(A[:n-k]))