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: Time Limit Exceeded

Solution code:
n, k = list(map(int, input().split()))
h = list(map(int, input().split()))
for i in range(k):
  h[h.index(max(h))] = 0
print(sum(h))

Submission status: Time Limit Exceeded

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

H.sort(reverse=True)

K = min(K, len(H))
for k in range(K):
    H.pop(0)

print(sum(H))

Submission status: Accepted

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

Submission status: Accepted

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

print(sum(h[k:]))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

print(sum(h[k:]))

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
nn, kk = list(map(int,input().split()))
hh = list(map(int,input().split()))
hh.sort()
if nn <= kk:
    print(0)
else:
    print(sum(hh[0:nn-kk]))

Submission status: Accepted

Solution code:
import re
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def v(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 6)
mod = 10**9+7
cnt = 0
ans = 0
inf = float("inf")
al = "abcdefghijklmnopqrstuvwxyz"
AL = al.upper()

n, k=I()
h = l()
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()
    ans = 0
    for i in range(n-k):
        ans += h[i]
    print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

h.sort(reverse = True)

print(sum(h[k:]))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
H=list(map(int, input().split()))
if K>=N: exit(print(0))
import heapq
H=[-i for i in H]
heapq.heapify(H)

for i in range(K):
	heapq.heappop(H)
print(-sum(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[k:])
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, K = map(int,input().split(' '))
H_ls = list(map(int, input().split(' ')))
H_ls.sort(reverse=True)
print(sum(H_ls[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<=0:
  print(0)
else:
  print(sum(h[k:]))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import bisect, collections, copy, heapq, itertools, math, string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int, sys.stdin.readline().rstrip().split())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

from  collections import defaultdict
from collections import Counter
import bisect
from functools import reduce

def main():
    N, K = MI()
    H = LI()
    H.sort(reverse=True)
    ans = sum(H[K:])
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

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

Submission status: Accepted

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

H = sorted(H)
hp = 0
for i in range(N-K):
  hp += H[i]
print(hp)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
num, deathblow = map(int, input().split())
enemy_table = list(map(int, input().split()))
list.sort(enemy_table, reverse=True)
sum = 0
if num <= deathblow:
    print(0)
else:
    for i in range(deathblow):
        enemy_table[i] = 0
    for j in range(num):
        sum += enemy_table[j]
    print(sum)

Submission status: Accepted

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

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

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
n,k = map(int,input().split())
health = list(map(int,input().split()))
s_health = sorted(health)
if n <= k:
    print(0)
    exit()

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

Submission status: Accepted

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

Submission status: Accepted

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

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N,K=MI()
    h=LI()
    
    h.sort()
    
    if K>=N:
        print(0)
        exit()
        
    for i in range(K):
        h[-1-i]=0
        
    ans=sum(h)
    print(ans)

main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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


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

Submission status: Accepted

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

a = 0

if K > N:
  a = K - N

for _ in range(a):
  H.append(0)

H.sort(reverse = True)
sum = 0

for i in range(K):
  H[i] = 0
  
for i in range(N):
  sum += H[i]
  
print(sum)

Submission status: Accepted

Solution code:
N,K= map(int, input().split())
list = list(map(int, input().split())) #Hiを入力

list.sort()
if N>=K:
    while K>=1:
        del list[-1]
        K=K-1
else:
    list.clear()

x=0
for i in list:
    x=x+i

print(str(x))

Submission status: Accepted

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

h = sorted(h,reverse=True)

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

print(ans)

Submission status: Accepted

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

enemy.sort(reverse=True)

if k >= n :
  print(0)

else:
  

  for x in range(k):
    enemy[x] = 0
  
  print(sum(enemy))

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
H = list(map(int, input().split()))
 
# N<=Kの場合、全てのモンスターを必殺技で倒して終了
# N>Kの場合、N体のモンスターのうち、体力が高い順に、K体を必殺技で倒す
# 残ったモンスターは、攻撃によって倒す
# 攻撃の回数を求める（必殺技は数えない）ことに注意する

# 計算量はO(NlogN)で間に合う
H = sorted(H, reverse=True)
ans = 0
if N > K: ans = sum(H[K:])
  
print(ans)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
def main():
    N, K = map(int, input().split())
    H = sorted([int(x) for x in input().split()])

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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
import heapq

n, k = map(int, input().split())
h = []
heapq.heapify(h)
for x in map(int, input().split()):
  heapq.heappush(h, x)

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

ans = 0
for x in range(n - k):
  ans += heapq.heappop(h)

print(ans)

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

H.sort(reverse=True)

if K<=len(H):
  print(sum(H[K:len(H)+1]))
else:
  print(0)

Submission status: Accepted

Solution code:
import sys

input = sys.stdin.readline


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


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

Submission status: Accepted

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

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:
#!/usr/bin/env python3
import sys
from itertools import chain


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


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


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
# C - Fennec vs Monster

n,k = map(int,input().split())
h = list(map(int,input().split()))
h.sort(reverse=True)
if k >= n:
    k = n
h2 = h[k:]

print(sum(h2))

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:
# -*- coding: utf-8 -*-
"""
Created on Tue Sep  8 01:07:55 2020

@author: liang
"""

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

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

Submission status: Accepted

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

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

h.sort(reverse = True)

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(sorted(map(int, input().split())))
x = 0
if n > k:
    for i in range(n - k):
        x += h[i]

print(x)

Submission status: Accepted

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

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(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)
ans = 0
for i in range(k,n):
    ans += h[i]
print(ans)

Submission status: Accepted

Solution code:

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

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
N,K = list(map(int, input().split(" ")))
H = sorted(list(map(int, input().split(" "))), reverse=True)
Z = 0
R = 0
for n,e in enumerate(H):
  if (n == K):
    Z = n
    break
  elif (K >= len(H)):
    Z = len(H)
    break
for i in H[Z:]:
  R += i
print(R)

Submission status: Accepted

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

if len(b) <= a[1]:
    print("0")
elif a[1]==0:
    print(sum(b))
else:
    b.sort(reverse=True)
    print(sum(b[a[1]:]))

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
A = list(map(int, input().split()))
A = sorted(A, reverse = True)
for i in range(min(K, N)):
  A[i] = 0
ans = sum(A)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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


    
for i in range(len(H)-K):
    SUM = SUM + H[i]


print(SUM)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,k=map(int,input().split())  
h =list(map(int,input().split()))
if k>=n:
    print(0)
else:

    h.sort()
    ans = sum(h[:n-k])
    print(ans)

Submission status: Accepted

Solution code:
z=list(map(int,input().split()))
x=list(map(int,input().split()))
x.sort(reverse=True)
d=0
c=0
for i in x:
       if c>=z[1]:
              d+=i
       c+=1
print(d)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
from sys import exit
import math
import collections
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

n,k = mi()
h = li()
h.sort()
h.reverse()
sum = 0
for i in range(k,n,1):
    sum += h[i]
print(sum)

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
h=map(int,input().split())
s=0
if n <= k:
    print("0")
else:
    if k==0:
        s=sum(h)
        print(s)
    else: 
        x=sorted(h)
        for i in range (0, k):
            x.pop()
        s=sum(x)
        print(s)

Submission status: Accepted

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

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

Submission status: Accepted

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

for i in range(min(k,n)):
    H[i] = 0

print(sum(H))

Submission status: Accepted

Solution code:
n,d=list(map(int,input().split()))
s=list(map(int,input().split()))
s=sorted(s)
s.reverse()
if d>=n:
    print(0)
else:
    c=0
    s=s[d:n]
    for i in s:
        c+=int(i)
    print(c)

Submission status: Accepted

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

Submission status: Accepted

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

H_list_min = sorted(H_list)
H_list_sum = 0

for i in range(len(H_list_min)-K):
    H_list_sum += H_list_min[i]

print(H_list_sum)

Submission status: Accepted

Solution code:
import heapq
(N,K) = map(int,input().split())
h = [int(x)*-1 for x in input().split()]
ans = 0
heapq.heapify(h)
if K <= N:
    for i in range(K):
        heapq.heappop(h)

    while h != []:
        ans -= heapq.heappop(h)

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import heapq
N,K = map(int,input().split())
Hlist = list(map(int,input().split()))
for i in range(len(Hlist)):
    Hlist[i] *= -1
heapq.heapify(Hlist)
for _ in range(min(K,N)):
    heapq.heappop(Hlist)
print(-sum(Hlist))

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

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
H = list(map(int, input().split()))
 
# N<=Kの場合、全てのモンスターを必殺技で倒して終了
# N>Kの場合、N体のモンスターのうち、体力が高い順に、K体を必殺技で倒す
# 残ったモンスターは、攻撃によって倒す
# 攻撃の回数を求める（必殺技は数えない）ことに注意する

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

Submission status: Accepted

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

cnt = 0
H.sort(reverse=True)

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

Submission status: Accepted

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

if k == 0:
  print(sum(h))
  sys.exit()

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    N, K = map(int, readline().split())
    H = list(map(int, readline().split()))
    H.sort()

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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
import sys

n,k=map(int,input().split())
H=list(map(int,input().split()))
H.sort()
if n>k:
    for i in range(k):
        H[n-1-i]=0
else:
    print(0)
    sys.exit()
    
sum_H=sum(H)
print(sum_H)

Submission status: Accepted

Solution code:
N, K = list(map(int, input().split()))
H = list(map(int, input().split()))
H = sorted(H, reverse=True)
for i in range(min(K,len(H))):
  H[i] = 0
print(sum(H))

Submission status: Accepted

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

h.sort(reverse=True)

if len(h)<=k:
    print('0')
    sys.exit()
else:
    del h[0:k]

a=sum(h)

print(a)

Submission status: Accepted

Solution code:
a,b=input().split()
a=int(a)
b=int(b)
c=list(map(int,input().split()))
c.sort()
d=sum(c)
e=0
if a<=b:
  print(0)
else:
  for i in range(1,b+1):
    e=e+c[-i]
  print(d-e)

Submission status: Accepted

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

H_sort = sorted(H)

#print (H)

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

Submission status: Accepted

Solution code:
n,k = map(int,input().split())
h = list(map(int,input().split()))
m = sorted(h,reverse=True)
if n <= k:
  print(0)
  exit()

q = sum(m[k:n])
print(q)

Submission status: Accepted

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

H=sorted(H)[::-1]

for i in range(min(N,K)):
    H[i] = 0

ans =sum(H)
print(ans)

Submission status: Accepted

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

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

    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

H.sort()
print(sum(H[:max(n-k, 0)]))

Submission status: Accepted

Solution code:
N, K=input().split()
hp=input().split()
j = sorted([int(x) for x in hp])
print(sum([j[x] for x in range(int(N) - int(K))])) if int(K) < int(N) else print(0)

Submission status: Accepted

Solution code:
n, k =map(int, input().split())
hitpoint=list(map(int,input().split()))
hitpoint.sort()
exe=[0]*k
if k!=0:
  hitpoint[-k:]=exe
  print(sum(hitpoint))
  exit(0)
else:
  print(sum(hitpoint))

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

H.sort()
remain = max(0, N-K)
H = H[:remain]

print(sum(H))

Submission status: Accepted

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

print(str(ans))

Submission status: Accepted

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

Submission status: Accepted

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

if N <= K:
  print(0)
  
else:
  H = list(map(int, input().split()))
  H.sort()
  H.reverse()
  
  c = 0
  for i in range(K, N):
    c += H[i]
  print(c)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

H=sorted(H,reverse=True)
sum_damage=0
for i in range(K,N):
    sum_damage+=H[i]

print(sum_damage)

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import os, sys, re, math

(N, K) = [int(n) for n in input().split()]
H = [int(n) for n in input().split()]

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
teki, hissatsu = list(map(int, input().split(' ')))
l = sorted(list(map(int, input().split(' '))))[:max(0, teki-hissatsu)]
print(sum(l))

Submission status: Accepted

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

Submission status: Accepted

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

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,n):
    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")
  exit()

ans = 0

def quicksort(a):
  if len(set(a)) < 2:
    return a
  left = []
  center = a.pop(0)
  right = []
  for i in a:
    if i > center:
      right.append(i)
    else:
      left.append(i)
  left = quicksort(left)
  right = quicksort(right)
  left.append(center)
  left.extend(right)
  return left

H = quicksort(H)

for i in range(N-K):
  ans += H[i]

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

if K>=N:
    print(0)
    exit()
H.sort(reverse=True)
H=H[K:]
print(sum(H))

Submission status: Accepted

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