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:
import sys
from random import choice,randint
inp=sys.stdin.readline
out=sys.stdout.write
flsh=sys.stdout.flush
 
sys.setrecursionlimit(10**9)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]
 
def MI(): return map(int, inp().strip().split())
def LI(): return list(map(int, inp().strip().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines().strip()]
def LI_(): return [int(x)-1 for x in inp().strip().split()]
def LF(): return [float(x) for x in inp().strip().split()]
def LS(): return inp().strip().split()
def I(): return int(inp().strip())
def F(): return float(inp().strip())
def S(): return inp().strip()
def pf(s): return out(s+'\n')
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)

def main():
    n,k=MI()
    h=LI()
    h.sort()
    if n<=k:
        print(0)
    else:
        x=n-k
        s = sum(h[:x])
        print(s)

if __name__ == "__main__":
    main()

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
if __name__ == '__main__':
    b, c = map(int, input().split())
    a = [int(i) for i in input().split()]
    a.sort(reverse=True)
    count = 0

    for i in a:
        if c >=1:
            c = c -1
        else:
            count = count + i
    print(count)

Submission status: Accepted

Solution code:
def main():
    N, K = map(int, input().split())
    H = list(map(int, input().split()))
    H = sorted(H)[::-1]
    if K >= len(H):
        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()))

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

Submission status: Accepted

Solution code:
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import bisect

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

def LI(): return list(map(int, sys.stdin.readline().split()))

N, K = LI()
H = LI()
H.sort()
ans = 0
if K >= len(H):
    print(0)
    sys.exit()

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

Submission status: Accepted

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


main()

Submission status: Accepted

Solution code:
N, K = map(int,input().split()) # 複数の数字を変数に格納
List = list(map(int,input().split())) # 複数の数字をリストに格納

List.sort()
attack = 0
enemy = N - K

for i in range(enemy):
    attack += List[i]

print(attack)

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(reverse=True)
    ret = 0
    for i in h[k:]:
        ret += i
    print(ret)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return list(map(int, sys.stdin.readline().split()))
def II(): return int(sys.stdin.readline())
def LS(): return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]

def main():
    n, k = LI()
    hs = sorted(LI(), reverse=True)
    if k >= n:
        print(0)
    else:
        print(sum(hs[k:]))

if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

h.sort(reverse=True)
n_h = h[k:]
print(sum(n_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:
h,k=map(int,input().split())
H=list(map(int,input().split()))
H.sort()
if k<h:
    print(sum(H[:h-k]))
else:
    print(0)

Submission status: Accepted

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

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

Submission status: Accepted

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

H.sort(reverse=True)

ans=sum(H[K:N])

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n, k = map(int, input().split(" "))
hs = sorted(map(int, input().split(" ")), reverse=True)
nokori = hs[k:]
out = sum(nokori)
print(out)

Submission status: Accepted

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

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

ans = sum(H[:max(N - K, 0)])

print(ans)

Submission status: Accepted

Solution code:

def resolve():
    N,K =(int(i) for i in input().split())
    H=[int(i) for i in input().split()]
    H.sort(reverse=True)
    if K>=N:
        print(0)
        return
    print(sum(H[K:]))






if __name__ == "__main__":
    resolve()

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
from itertools import permutations, combinations
from fractions import gcd
from collections import Counter
from math import sqrt
import sys
input = sys.stdin.readline
def lcm(x, y):
    return (x*y//gcd(x, y))
def small_letters():
    return [chr(i) for i in range(97, 97+26)]
def capital_letters():
    return [chr(i) for i in range(65, 65+26)]
def continual_letters(list_x):
    """example"""
    """[2,2,2,2,4,4,5,5,5,8,8,8,8,8] => [4,2,3,5]"""
    i,j = 0,0
    result = []
    k = len(list_x) - 1
    while(True):
        A = list_x[i]
        while(True):
            print(j)
            if list_x[j] != A:
                break
            if j >= k:
                break
            j += 1
        result.append(j-i)
        if i >= k:
            break
        i = j
    result[-1] += 1
    return result


def main():
    """ここに書いてね"""
    N,K = map(int,input().split())
    HPs = list(map(int,input().split()))
    HPs.sort()
    if K >= N:
        print(0)
    else:
        print(sum(HPs[:N-K]))

if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

    H.sort()
    h = H[:N-K]
    print(sum(h))


if __name__ == "__main__":
    main()

Submission status: Accepted

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

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

if K >= N:
    print(0)
else:
    for i in range(K):
        newH.pop()
    print(sum(newH))

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:
# Keyence 2020 A
si = lambda: input()
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import numpy as np

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

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

H_sort = np.sort(np.array(H))[::-1]

print(int(H_sort[K:].sum()))

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

Submission status: Accepted

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

out=0
if b==0:
    for i in A:
        out+=i
else:
    for i in A[:-b]:
        out+=i

print(out)

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

Submission status: Accepted

Solution code:
def main():
    n,k=map(int,input().split())
    h=sorted(list(map(int,input().split())))
    if k>=n:
        print(0)
    else:
        for i in range(k):
            _=h.pop(-1)
        print(sum(h))
    
if __name__ == '__main__':
    main()

Submission status: Accepted

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

count = 0

h.sort(reverse = True)

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

for i in range(n):
    count += h[i]

print(count)

Submission status: Accepted

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


def solve(N: int, K: int, H: "List[int]"):
    if N <= K:
        print(0)
        return

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


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

h.sort()
h.reverse()

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

Submission status: Accepted

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

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

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

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

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

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

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

def main():
	N,K = inputMap()
	H = inputList()

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

	ans = 0
	for i,vol in enumerate(H):
		if K > 0:
			K -= 1
			#print(K)
			continue
		ans += vol

	print(ans)




if __name__ == "__main__":
	main()

Submission status: Accepted

Solution code:
import math
x,y=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
if y>=x:
    print(0)
else:
    print(sum(a[:x-y]))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

# print(h)


new_h=h[0:max(n-k,0)]
# print(new_h)

print(sum(new_h))

Submission status: Accepted

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

H.sort()
K = min(K, N)
ans = sum(H[: N - K])
print(ans)

Submission status: Accepted

Solution code:
import math
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 main():
    N, K = map(int, input().split())
    HN = list(map(int, input().split()))

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


main()

Submission status: Accepted

Solution code:


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


lst.sort(reverse=True)

print(sum(lst[K:]))

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:
    break
  H.pop(-1)
print(sum(H) if len(H) > 0 else 0)

Submission status: Accepted

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

h.sort(reverse=True)

del h[0:k]

print(sum(h))

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
h=list(map(int,input().split()))
if k>=n:
  print(0)
  exit()
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())
H = sorted([int(_) for _ in input().split()], reverse=True)
ans = 0
for n in range(N):
    if n > K - 1:
        ans += H[n]
print(ans)

Submission status: Accepted

Solution code:


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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

h_list.sort(reverse=True)

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
n, k = map(int, input().split())
h_list = list(map(int, input().split()))

h_list.sort()

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

H.sort()

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

Submission status: Accepted

Solution code:
import sys

def get_array(): return list(map(int, sys.stdin.readline().split()))
def get_ints(): return map(int, sys.stdin.readline().split())

n,k = get_ints()
Arr = get_array()

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

Arr.sort(reverse = True)
ans = 0
for i in range(k,n):
    ans+=Arr[i]
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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


def solve(N: int, K: int, H: "List[int]"):
    H.sort()
    ans = 0
    for i in range(N-K):
        ans += H[i]
    print(ans)

    
    return


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

Submission status: Accepted

Solution code:
# coding:utf-8

N, K = map(int, input().split(' '))
H = [int(h) for h in input().split(' ')]
H.sort(reverse=True)

print(sum(H[K:]))

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

A.sort()
A.reverse()
ans=sum(A)
for i in range(min(k,n)):
    ans-=A[i]
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
a=sorted(list(map(int,input().split())))
if n<=k:
    print(0)
elif 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()
if n <= k:
    print(0)
elif k == 0:
    print(sum(h))
else:
    h = h[0:-k]
    print(sum(h))

Submission status: Accepted

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

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

Submission status: Accepted

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

if k>=len(H):
       print(0)
       exit()

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 = [int(x) for x in 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=list(map(int,input().split()))
h.sort(reverse=True)
ans=0
for i in range(n):
    if k>0:
        k-=1
    else:
        ans+=h[i]
print(ans)

Submission status: Accepted

Solution code:
import math
a,b=map(int,input().split())
c=list(map(int,input().split()))
if b>=a:
    print(0)
else:
    c.sort()
    print(sum(c[:a-b]))

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n,k = [int(j) for j in input().split()]
l = [int(j) for j in input().split()]
l.sort()
l = l[::-1]
for i in range(min(k, n)):
    l[i] = 0
print(sum(l))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().rstrip()

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

if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

# HPで降順ソート
H = sorted(H,reverse=True)


# 最初のK匹には必殺技
# 残りの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()))
h.sort()
if k > n:
    print(0)
    exit()
total = sum(h[0: n - k])
print(total)

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:
        ans += h[i]

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
(n, k), *D, = [list(map(int, s.split())) for s in open(0)]
D = D[0]

D = sorted(D, reverse=True)
print(sum(D[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()))
H.sort()
print(sum(H[:-K]) if K > 0 else sum(H))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
def A():
    temp = [int(i) for i in input().split()]
    print(int(math.ceil(temp[0]/temp[1])))

def B():
    temp = [int(i) for i in input().split()]
    H = temp[0]
    N = temp[1]
    A = [int(i) for i in input().split()]
    if H <= sum(A):
        print('Yes')
    else:
        print('No')

def C():
    temp = [int(i) for i in input().split()]
    N = temp[0]
    K = temp[1]
    H = [int(i) for i in input().split()]
    if N <= K:
        print(0)
        return
    H.sort(reverse=True)
    print(sum(H[K:]))
    
C()

Submission status: Accepted

Solution code:
import sys
def I(): return int(sys.stdin.readline())
def LI(): return [int(x) for x in sys.stdin.readline().split()]

def main():
    N,K = LI()
    H = LI()

    H.sort()

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

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import sys, re, os
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 S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

def main():
    n, k = MAP()
    H = LIST()
    H.sort(reverse=True)
    print(sum(H[k:]))




if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:

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

Submission status: Accepted

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

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

ans = sum(H[K:])

print(ans)

Submission status: Accepted

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

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

if __name__ == '__main__':
    solve()

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())
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:
import math
import sys

m=10**9 + 7 
sys.setrecursionlimit(1000010)
(N, K) = list(map(int,input().split()))
H  = list(map(int,input().split()))
H.sort(reverse=True)
# print(H)

if K >= len(H):
    print(0)
    exit(0)

Hrest = H[K:]
# print(Hrest)
ans = sum(Hrest)
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n,k,*h=map(int,open(0).read().split())
h.sort()
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())

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

monster = len(hps)

hps = sorted(hps, reverse=True)

for i in range(k):
    hps[i % monster] = 0

print(sum(hps))

Submission status: Accepted

Solution code:
import math
import sys
#n = int(input())
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 = (int(i) for i in input().split())
H = sorted([int(i) for i in input().split()],reverse=True)
print(sum(H[k:]))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding=utf-8
# Date: 2020-01-08
# Author: lee215

get = lambda: int(raw_input().strip())
getl = lambda: raw_input().strip()
gets = lambda: map(int, raw_input().strip().split())
getss = lambda n: [gets() for _ in xrange(n)]


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