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

    sorted_H = sorted(H,reverse=True)

    for i in range(K):
        if(i < len(sorted_H)):
            sorted_H[i] = 0

    '''
    for _ in range(K):
        if(len(H) > 0):
            maximum = max(H)
            H.remove(maximum)
            '''

    print(sum(sorted_H))

if __name__ == "__main__":
    main()

Submission status: Accepted

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

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

Submission status: Accepted

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

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

if n <= k:
    print(0)
else:
    for i in range(k):
        h_s.pop()
    print(sum(h_s))

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
def fenec(k, h_list):
  h_list.sort()
  if k >= len(h_list):
    return 0
  else:
    ans = 0
    for i in range(len(h_list)-k):
      ans += h_list[i]
    return ans
    
n, k = [int(i) for i in input().split()]
h_list = [int(i) for i in input().split()]

print(fenec(k, h_list))

Submission status: Accepted

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

def check(N,K,H):
    count = 0
    H = sorted(H)
    if K >= len(H):
        return 0
    H = H[0:len(H)-K]
    return sum(H)

ans = check(N,K,H)
print(ans)

Submission status: Accepted

Solution code:

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

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

Submission status: Accepted

Solution code:
from sys import stdin

def main():
    input = stdin.readline

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

    H.sort(reverse=True)

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

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
h,a = [int(x) for x in input().rstrip().split()]
l=[int(x) for x in input().rstrip().split()]
l.sort(reverse = True)

ans=0

del l[0:a]
ans = a
print(sum(l))

Submission status: Accepted

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

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

if k >= n:
  print(0)
else:
  h.sort(reverse=True)
  ans += sum(h[k:])
  print(ans)

Submission status: Accepted

Solution code:
n,k = input().strip().split()
n,k = [int(n), int(k)]
h = list(map(int, input().strip().split()))
h.sort()
count = 0

if k >= n:
  print("0")
else:
  for v in range(n-k):
    count += h[v]
  print(count)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,k = map(int,input().split())
h = [i for i in map(int,input().split())]
h.sort()
while k > 0:
  if h==[]:
    h.append(0)
    break
  h.pop(-1)
  k -= 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:
    del h[:k]
    print(sum(h))
else:
    print(0)

Submission status: Accepted

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

Submission status: Accepted

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

others = sorted(h_n, reverse=True)[k:]
print(sum(others))

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

if n <= k:
    print(0)
else:
    lst = sorted(lst, reverse=True)
    print(sum(lst[k:]))

Submission status: Accepted

Solution code:
N = list(map(int,input().rstrip().split()))
n = N[0]
k = N[1]

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

m = 0
hit = 0
if k >= n :
  m = 0
else:
  for i in range(k,n):
    hit += h[i]
  
  m = hit
print(m)

Submission status: Accepted

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

Submission status: Accepted

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

H.sort(reverse=True)

k_count = 0
for h in H:
    if k_count < K:
        k_count += 1
    else:
        break
print(sum(H[k_count:]))

Submission status: Accepted

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

ans = 0
while n > k:
  ans += H[k]
  k += 1
else:
  print(ans)

Submission status: Accepted

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

H_S = sorted(H)

res = 0
for i in range(max(0, N-K)):
    res = res + H_S[i]
print(res)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

num_list.sort()
sum = 0

if num[1] >= num[0]:
  ans = 0
elif num[1] < num[0]:
  for i in range(0,num[0]-num[1]):
    sum = sum + num_list[i]
    
  ans = sum

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import math
from fractions import gcd

import numpy as np
import scipy as scp

# 入力の受け取り
n,k = map(int,input().split())
arrH = np.array(input().split(),dtype=np.int64)

arrH.sort()

ans = sum(arrH[::-1][k:])

print(ans)

Submission status: Accepted

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

#Hを大きい順に並べ替え
H.sort(reverse=True)

#大きい順からK個必殺技
del H[0:K]

#残ったリストの要素の合計
print(sum(H))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
hp, n = map(int, input().split())
li = [int(i) for i in input().split()]
li.sort(reverse=True)
if len(li) < n:
  print(0)
  exit()
for i in range(n):
  li[i] = 0
print(sum(li))

Submission status: Accepted

Solution code:
# https://atcoder.jp/contests/abc153/tasks/abc153_c
import sys
sys.setrecursionlimit(12345678)
import itertools
from collections import Counter
from collections import defaultdict
from collections import deque
import bisect
from heapq import heappush, heappop


def main():
    n, k = map(int, input().split())
    hl = list(map(int, input().split()))
    hl.sort()
    rest = max(0, n-k)
    hl = hl[:rest]
    print(sum(hl))
    return


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
class Culuculation():
  N = 0
  K = 0
  H = []
  
  #初期化。ここで引数も受け取る
  def __init__(self):
    self.N, self.K = ( int(x) for x in input().split(' '))
    self.H = [int(x) for x in input().split(' ')]

  #計算処理
  def culc(self):
    self.H.sort(reverse=True)
    if self.N >= self.K:
      del self.H[0:self.K]
    else:
      self.H.clear()
    print(sum(self.H))

def main():
  tmp = Culuculation()
  tmp.culc()

if __name__=='__main__':
  main()

Submission status: Accepted

Solution code:
N, K = (int(x) for x in input().split(' '))
H    = [int(x) for x in input().split(' ')]
#ソート処理
list.sort(H, reverse=True)
#K回最大値をHから消す
if N >= K:
  del H[0:K]
else:
  H.clear()
#総和を出力
print(sum(H))

Submission status: Accepted

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

monsters.sort()

total_hp = 0
if(len(monsters) > k):
    for i in range(n-k):
        total_hp += monsters[i]
        
    print(total_hp)
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)
else:
  HP=sorted(H,reverse=True)
  del HP[:K]
  print(sum(HP))

Submission status: Accepted

Solution code:
N,K,*H=map(int,open(0).read().split())
print(sum(sorted(H)[:N-min(N,K)]))

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10 ** 7)
read = sys.stdin.buffer.read 
input = sys.stdin.buffer.readline
def inputS(): return input().rstrip().decode()
readlines = sys.stdin.buffer.readlines 

N, K = map(int, input().split())
A = sorted(map(int, input().split()), reverse=True)

ans = sum(A[K:])
print(ans)

Submission status: Accepted

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


def solve(N: int, K: int, H: "List[int]"):
    H = sorted(H, reverse=True)[K:]

    print(sum(H))


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

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
#ABC153C
import sys
n, k = map(int, sys.stdin.readline().split())
H = list(map(int, sys.stdin.readline().split()))
H.sort(reverse = True)
#print(H)

print(sum(H[k:]))

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
h=sorted(list(map(int,input().split())))
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()))

if n <= k:
    print(0)
else:
    print(sum(sorted(h,reverse=True)[k:]))

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

if len(h_list) <= k:
    print(0)
else:
    h_list.sort(reverse=True)
    for i in range(k):
        h_list[i] = 0
    print(sum(h_list))

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
h=list(map(int,input().split()))
h.sort()
h=h[::-1]
k=min(n,k)
ans=0
for i,x in enumerate(h):
  if i>=k:
    ans+=x
print(ans)

Submission status: Accepted

Solution code:
# N体の敵、K回の必殺技
N, K = map(int, input().strip().split(' '))
N_list = list(map(int, input().strip().split(' ')))
sorted_N = sorted(N_list, reverse=True)

# 必殺技で体力が多い敵からヤる
del sorted_N[:K]

if sorted_N ==[]:
  print(0)
else:
  print(sum(sorted_N))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n, k = list(map(int, readline().split()))
    h = list(map(int, readline().split()))
    h.sort(reverse=True)
    print(sum(h[k:n]))


if __name__ == '__main__':
    solve()

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(max(0, N - K)):
    ans += H[i]

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

count = 0
ans = 0
for i in sorted(h, reverse = True):
  if count < k:
    count += 1
    continue
  ans += i
print(ans)

Submission status: Accepted

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

h.sort(reverse = True)

ans = 0
for i in range(n):
    if i < k:
        continue
    ans += h[i] 

print(ans)

Submission status: Accepted

Solution code:
# Initializing variables
monsterCount, specialAttacks = map(int, input().split())
monsters = sorted(list(map(int, input().split())), reverse=True)
# NOTE: The sorted() function is in an ascending order in default. Now it's reversed.

# Calculating and judging the minimal number of attacks fennec needs to win.
if len(monsters) <= specialAttacks:
    print(0)
else:
    EntireMonsters = sum(monsters)
    destroyed = sum(monsters[:specialAttacks])
    print(EntireMonsters - destroyed)

# Check out my Youtube channel! https://www.youtube.com/channel/UCMOKVyAbTZOpKikTrX5dy_A

Submission status: Accepted

Solution code:
# Initializing variables
monsterCount, specialAttacks = map(int, input().split())
monsters = sorted(list(map(int, input().split())), reverse=True)
# NOTE: The sorted() function is in an ascending order in default. Now it's reversed.

# Calculating and judging the minimal number of attacks fennec needs to win.
if len(monsters) <= specialAttacks:
    print(0)
else:
    EntireMonsters = sum(monsters)
    destroyed = sum(monsters[:specialAttacks])
    print(EntireMonsters - destroyed)

Submission status: Accepted

Solution code:
from collections import deque

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

D = deque(H)

for _ in range(K):
    if N == 0:
        break
    D.pop()
    N -= 1

print(sum(D))

Submission status: Accepted

Solution code:
H,K=map(int,input().split())
A=list(map(int,input().split()))
B=sorted(A)
if len(B)<=K:
	print(0)
else:
	for i in range(1,K+1):
		B[-i]=0
	print(sum(B))

Submission status: Accepted

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


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

H.sort(reverse=True)

print(sum(H[k:]))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# ANSHUL GAUTAM
# IIIT-D

from math import *
from copy import *
from string import *                # alpha = ascii_lowercase
from random import *                # l.sort(key=lambda l1:l1[0]-l1[1]) => ex: sort on the basis difference
from sys import stdin
from sys import maxsize
from operator import *                # d = sorted(d.items(), key=itemgetter(1))
from itertools import *
from collections import Counter        # d = dict(Counter(l))
from collections import defaultdict # d = defaultdict(list)

'''

'''

def solve(l,k):
	n = len(l)
	l = sorted(l)
	if(k != 0):
		l = l[:-k]
	# print(l)
	ans = sum(l)
	return ans
	

N,K = map(int, stdin.readline().rstrip().split())
l = list(map(int, stdin.readline().rstrip().split()))
ans = solve(l,K)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
NK = list(map(int, input().split()))
Hi = list(map(int, input().split()))

N = NK[0]
K = NK[1]
Hi.sort()
reversed_Hi = list(reversed(Hi))

for i in range(len(reversed_Hi)):
    if not reversed_Hi:
        break

    if K == 0:
        break
    else:
        K -= 1
        reversed_Hi[i] = 0

count = 0
for i in reversed_Hi:
    count += i

print(count)

Submission status: Accepted

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

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

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


main()

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:
  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()))
if k>=n:
    print(0)
    exit()
h = sorted(h,reverse=True)
f = h[k:]
print(sum(f))

Submission status: Accepted

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

H.sort(reverse=True)
# print(H)
if K >= len(H):
    print(0)
    exit()
for i in range(K):
    H[i] = 0

ans = sum(H)

print(ans)

Submission status: Accepted

Solution code:
kazu1 = list(map(int, input().split()))
kazu2 = list(map(int, input().split()))
n = 0
kazu2.sort(reverse=True)

kazu2[:kazu1[1]] = [0]

n += sum(kazu2)

print(n)

Submission status: Accepted

Solution code:
import math

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

h.sort(reverse=True)

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

Submission status: Accepted

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

h.sort(reverse=True)

h = h[k:]

print(sum(h))

Submission status: Accepted

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

a = [int(s) for s in input().split()]
b = [int(s) for s in input().split()]

c = sorted(b)

d = c[:-a[1]] if a[1] != 0 else c

ans = sum(d)

print(ans)

Submission status: Accepted

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

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

H.sort()
count = 0
try:
    for _ in range(K):
        H.pop()
        count += 1

except:
    pass

ans = sum(H)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

sort_H=sorted(H)

for i in range(K):
    if(sort_H==[]):
        print('0')
        sys.exit()
    sort_H.pop()


print(sum(sort_H))

Submission status: Accepted

Solution code:
import sys
read = sys.stdin.buffer.read#全部読み込むやつ
readline = sys.stdin.buffer.readline#1行読み込むやつ
readlines = sys.stdin.buffer.readlines#リストで読み込むらしい

N,K,*H = map(int,read().split())
N -= K
if N <= 0:
    print(0)
    exit()
    
H.sort()
    
print(sum(H[: N]))

Submission status: Accepted

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

Submission status: Accepted

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

H.sort()

if K>=N:
  print(0)
else:
  h = H[:N-K]
  ans = 0
  for i in h:
    ans += i
  print(ans)

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

h = sorted(h)
sum_of_k = 0
if k >= n:
    print(0)
    exit()
for i in range(k):
    sum_of_k += h[len(h)-i-1]
ans = sum(h)-sum_of_k
print(ans if ans >=0 else 0)

Submission status: Accepted

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

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:
import sys
input = sys.stdin.buffer.readline
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getlist():
    return list(map(int, input().split()))
import math
import heapq
from collections import defaultdict, Counter, deque
MOD = 10**9 + 7
INF = 10**15


def main():
    n, k = getlist()
    nums = getlist()
    nums.sort()
    if n <= k:
        print(0)
        return
    if k == 0:
        print(sum(nums))
        return
    print(sum(nums[:-k]))

if __name__ == '__main__':
    main()

"""
9999
3

2916
"""

Submission status: Accepted

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

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

lisH.sort()
lisH = lisH[::-1]

lisH = lisH[K:]

if len(lisH) == 0:
    print(0)
else:
    print(sum(lisH))

Submission status: Accepted

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

for i in range(k):
	if i <= (n-1):
		h[i] = 0
	else:
		break
	

print(sum(h))

Submission status: Accepted

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

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

print(sum1)

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
hp=list(map(int,input().split()))
hp.sort(reverse=True)
print(sum(hp[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()
    H = H[:n-k]
    print(sum(H))

Submission status: Accepted

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

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

print(cnt)

Submission status: Accepted

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

H_list.sort()

if K >= len(H_list):
  print(0)
  
else:
  for i in range(K):
    H_list[-i - 1] = 0

  print(sum(H_list))

Submission status: Accepted

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

h2=sorted(h)

if n<=k:
    ans=0
else:
    ans=sum(h2[0:n-k:1])
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 k >= n:
    print(0)
else:
    for i in range(n):
        if i >= 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:
  a=h[k::]
  print(sum(a))

Submission status: Accepted

Solution code:
import math

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

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

Submission status: Accepted

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

hs.sort()

print(sum(hs[:len(hs)-k]))

Submission status: Accepted

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

#降順にソートしたリストを作る
new_h = sorted(h,reverse=True)

#必殺技はカウントしない、攻撃はモンスターの体力を加算
ans = 0
for i in range(n):
    if i <= k-1:
        ans += 0
    else:
        ans += new_h[i]

print(ans)

Submission status: Accepted

Solution code:
import sys
n,k = map(int,input().split())
a = list(map(int,sys.stdin.readline().split()))
a.sort(reverse=True)
ans = 0
for i in range(n):
  if i >= k:
    ans += a[i]
print(ans)

Submission status: Accepted

Solution code:

l = list(map(int, input().split()))
h = list(map(int, input().split()))
h.sort(reverse=True)
if l[1]>=l[0]:
    print(0)
else:
    for i in range(l[1]):
        h[i]=0
    print(sum(h))

Submission status: Accepted

Solution code:
attack = 0
monster, critical = map(int, input().split())
monster_life = list(map(int, input().split()))
monster_life.sort()
for i in range(monster - critical):
    attack = attack + monster_life[i]
print(attack)

Submission status: Accepted

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

ans = 0
del H[0:K]
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= sorted(H, reverse=True)
ans = sum(h_sort[K:])

print(ans)

Submission status: Accepted

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

h.sort(reverse=True)
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)
if k >= len(H):
    print(0)
if k<len(H):
    del H[:k]
    print(sum(H))

Submission status: Accepted

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

if k == 0:
    print sum(hlist)
else:
    print sum(sorted(hlist)[:-k])

Submission status: Accepted

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

#敵を弱い順に並べる
teki_list.sort()

if k != 0:
    #強いやつに必殺技を使う
    if k <= len(teki_list):
        del teki_list[-k:]
    else:
        del teki_list[:]

print(sum(teki_list))

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

h = sorted(h, reverse = True)

for i in range(k):
  if i == n:
    break
  h[i] = 0

a = 0
for i in h:
  a += i
print(a)

Submission status: Accepted

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

res = 0
for a in A[k:] :
    res += a

print(res)

Submission status: Accepted

Solution code:
N, K = [int(x) for x in input().strip().split()]
H = sorted([int(x) for x in input().strip().split()])
print(sum(H[:max(0, N-K)]))

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(reverse=True)
del h[0:k]
x=sum(h)
print(x)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,K = list(map(int,input().split()))
A = list(map(int,input().split()))
B = sorted(A)
if N <= K:
    print(0)
else:
    for i in range(K):
        B.pop(-1)

    print(sum(B))

Submission status: Accepted

Solution code:
inp = input().split()
n,k = map(int, inp)
nums = list(input().split())
nums_list = list(map(int, nums))
kill_en_hp = 0
if len(nums_list) < k:
    print(0)
else:
    nums_list.sort(reverse=True)
    nums_list_2 = nums_list[k:]
    print(sum(nums_list_2))