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:
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:
from sys import stdin
import sys
import math
from functools import reduce
import itertools

n,k = [int(x) for x in stdin.readline().rstrip().split()]
h = [int(x) for x in stdin.readline().rstrip().split()]

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

hs = sorted(h,reverse=True)

print(sum(hs[k:]))

Submission status: Accepted

Solution code:
import sys
import time
import math
import itertools as it
def inpl():
    return list(map(int, input().split()))
st = time.perf_counter()
# ------------------------------

N, K = inpl()
H = inpl()
H.sort()
H.reverse()
for i in range(K):
    if len(H) == i:
        break
    H[i] = 0
print(sum(H))

# ------------------------------
ed = time.perf_counter()
print('time:', ed-st, file=sys.stderr)

Submission status: Accepted

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


def II():
    return int(sys.stdin.readline())


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


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


def main():
    n, k = MI()
    H = LI()
    H.sort()
    H.reverse()

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


main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    n, k = map(int, input().split())
    h = [int(x) for x in input().split()]
    h_s = sorted(h)
    if len(h_s) <= k:
        ans = 0
    else:
        for _ in range(k):
            h_s.pop()
        ans = sum(h_s)
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Accepted

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


def main():
  N, K = list(map(int, input().split()))
  H = list(map(int, input().split()))
  H = sorted(H)

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


if(__name__ == '__main__'):
  main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,K=map(int,input().split())
I=list(map(int,input().split()))
H=[]
I=sorted(I,reverse=True)
H=I[K:]
s=0
for i in H:
  s+=i
print(s)

Submission status: Accepted

Solution code:
# import itertools
# import math
import sys

# N = int(input())
# S = input()
# n, *a = map(int, open(0))
N, K = map(int, input().split())
H = list(map(int, input().split()))
# Q = list(map(int, input().split()))
# S = input()


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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import bisect,collections,copy,heapq,itertools,math,string
import numpy as np
import sys
sys.setrecursionlimit(10**7)

def _S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())

N,K = LI()
H = LI()

Hs = np.array(sorted(H, reverse=True))

ans = np.sum(Hs[K:])

print(ans)

Submission status: Accepted

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

print(sum(h[k:]))

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
from collections import Counter as Ct
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))

def do():
    n,k=INTM()
    a=LIST()
    a=sorted(a,reverse=True)
    if n<=k:
        ans=0
    else:
        ans=sum(a[k:])

    print(ans)
if __name__=='__main__':
    do()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# C - Distinct or Not
N, K = map(int, input().split())
H = list(map(int, input().split()))
H = sorted(H, reverse=True)

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

ans = sum(H)
print(ans)

Submission status: Accepted

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

if n<=k:
  print(0)
  
else:
  a=sorted(a)
  b=n-k
  ans=0
  for x in range(n-k):
    ans+=a[x]
    
  print(ans)

Submission status: Accepted

Solution code:
n1, n2 = [int(i) for i in input().split()]

n3 = [int(j) for j in input().split()]

n3.sort(reverse=True)

n4 = 0
for i1 in range(n1):
    if i1 >= n2:
        n4 += n3[i1]
print(n4)

Submission status: Accepted

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

temp = sorted(H,reverse=True)
new_H = temp[K:len(temp)]

if(N-K<=0):
    print(0)
else:
    print(sum(new_H))

Submission status: Accepted

Solution code:
#153_C
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())
list_H = list(map(int,input().split()))
list_H.sort(reverse=True)
list_H = list_H[K:]
print(sum(list_H))

Submission status: Accepted

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

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

for i in range(min(K,N)):
    Monsters[i]=0
print(sum(Monsters))

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N,K,*H = map(int, open(0).read().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())))

for p in range(K):
    if N-p-1 >= 0:
        H[N-p-1] = 0

print(sum(H))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
import heapq
import math
import fractions
import bisect
import itertools
from collections import Counter
from collections import deque
from operator import itemgetter
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

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

Submission status: Accepted

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

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:N]))

Submission status: Accepted

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

Submission status: Accepted

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

if n <= k :
    print(0)
else :
    for i in range(k) :
        enemy[i] = 0
    print(sum(enemy))

Submission status: Accepted

Solution code:
from collections import deque
N,K = map(int,input().split())
H = list(map(int,input().split()))
H.sort(reverse=True)
deqH = deque(H)
if N <= K:
    print(0)
else:
    for i in range(K):
        deqH.popleft()
        #H.remove(max(H))
        #print(H)
    print(sum(deqH))

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,*h=map(int,open(0).read().split())
if k>=n:
    print(0)
else:
    h.sort()
    print(sum(h[:n-k]))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
nMonsters, nSpecial = [int(x) for x in input().split()]

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

monst.sort()

nMonsters -= nSpecial

if nMonsters < 0:
    print(0)
else:
    print(sum(monst[0:nMonsters]))

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 : n + 1]))

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
N, K = [int(x) for x in input().split()]
H = [int(x) for x in input().split()]
H.sort()
if(N<K):
  print(0)
  sys.exit()
else:
  for i in range(1,K+1):
    H[N-i] = 0
print(sum(H))

Submission status: Accepted

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

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 = [int(x) for x in input().split()]
Ha = sorted(H, reverse=True)
del Ha[:K]
print(sum(Ha))

Submission status: Accepted

Solution code:
a,b=map(int, input().split())
c=sorted(list(map(int, input().split())),reverse = True)

ans = 0

if b >= a:
    c = [0]
if b < a:
    for i in range(b):
        c[i] = 0

print(sum(c))

Submission status: Accepted

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

Submission status: Accepted

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

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

print(m)

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>=n:
    print(0)
else:
  H.sort(reverse=True)
  for i in range(k):
    H[i] = 0

  print(sum(H))

Submission status: Accepted

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

Submission status: Accepted

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

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

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

h=sorted(h,reverse=True)

s=h[k:]

print(sum(s))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,K = list(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())
if K >= N:
    print(0)
    exit()
H = sorted(list(map(int, input().split())))
print(sum(H[0: N - K]))

Submission status: Accepted

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

(n, k), s, c = map(int, input().split()), sorted(list(map(int, input().split())), reverse = True), 0
for i in range(n-k): c += s.pop()
print(c)

Submission status: Accepted

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

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

if K >= N:
    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(reverse=True)

if k == 0 :
    print(sum(h))
elif k <= n :
    for i in range(k):
        h[i] = 0
    print(sum(h))
else :
    print(0)

Submission status: Accepted

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

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

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

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

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


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

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

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


s=0
if k>=n:
    s=0
    print(s)
else:
    c=merge_sort(h)
    c.reverse()

    s=0
    for a in range(n-k):
        s=s+c[a+k]
    
    print(s)

Submission status: Accepted

Solution code:
import sys

n,k = map(int,input().split())
ans = 0;
h = [int(x) for x in input().split()]
h.sort(reverse = True)
h = h[k:]

if len(h) > 0:
    ans += sum(h)

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

h.sort(reverse = True)
t = 0

del h[0:k]
    
if len(h) == 0 :
    print(0)
else:
    t += sum(h)
    print(t)

Submission status: Accepted

Solution code:
from sys import exit

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

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

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)

remainder = H[K:]

print(sum(remainder))

Submission status: Accepted

Solution code:
if __name__ == '__main__':

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

	num = len(A) - min(n,k)

	print(sum(A[0:num]))

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline

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

ans = 0
h.sort(reverse=True)
for i in h:
    if 0 < k: k -= 1
    else:
        ans += i

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
n, k, *h = map(int, open(0).read().split())
print(sum(sorted(h)[-k-1::-1]))

Submission status: Accepted

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

if n <= k:
    print(0)
    exit()
ans = 0
for h in H[: n - k]:
    ans += h
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()))

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

print(rh2)

Submission status: Accepted

Solution code:
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, K, *H = map(int, read().split())
    
    H.sort(reverse=True)
    print(sum(H[K:]))
    
    return


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
Hlist = list(map(int, input().split()))
Hlist = sorted(Hlist)[::-1]
#user K super attack for largest K enemy
remainHlist = Hlist[K:]
attackTimes = sum(remainHlist)
print(attackTimes)

Submission status: Accepted

Solution code:
import math

def main():
  N, K = map(int, input().split())
  H = list(map(int, input().split()))
  
  if K >= N:
    print(0)
    return
  
  #ans = 0
  l = sorted(H, reverse=True)
  
  # del l[:K]
  # print(l)
  
  # ans += sum(l)
  
  print(sum(l[K:]))
  #print(ans)
  
  
main()

Submission status: Accepted

Solution code:
import sys

def II(): return int(input())
def MI(): return map(int,input().split())
def LI(): return list(map(int,input().split()))
def TI(): return tuple(map(int,input().split()))
def RN(N): return [input().strip() for i in range(N)]


def main():
    N, K = MI()
    H = LI()
    Hs = sorted(H)
    ans = 0

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

if __name__ == "__main__":
	main()

Submission status: Accepted

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

print(sum(mon[k:]))

Submission status: Accepted

Solution code:
import sys

N, K = (int(x) for x in input().split())
H = list(map(int, input().split()))
ans=0

if K>=N:
  print(0)
  sys.exit(0)
  
H.sort(reverse=True)
del H[0:K]
for i in range(len(H)):
  ans+=H[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)
H = H[K:N]
print(sum(H))

Submission status: Accepted

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

h.sort()

s = min(k, n)
if s:
    answer = sum(h[:-s])
else:
    answer = sum(h)
print(answer)

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
H = list(map(int, input().split()))
H.sort()
count = 0
for i in range(0, 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 n <= k:
  print('0')
  exit()

H.sort()
H.reverse()
print(sum(H)-sum(H[0:k]))

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

h.sort()

h = h[::-1]
h = h[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)
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())
    inlis = list(map(int, input().split()))
    inlis.sort()
    #print(inlis)

    if k >= n:
        print(0)
        exit()
    elif k > 0:
        total = sum(inlis[:-k])
    elif k == 0:
        total = sum(inlis)
    print(total)

    
if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
#import string
#from collections import defaultdict, deque, Counter
#import bisect
#import heapq
#import math
#from itertools import accumulate
#from itertools import permutations as perm
#from itertools import combinations as comb
#from itertools import combinations_with_replacement as combr
#from fractions import gcd
#import numpy as np

stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)
MIN = -10 ** 9
MOD = 10 ** 9 + 7
INF = float("inf")
IINF = 10 ** 18

def solve():
    #n = int(stdin.readline().rstrip())
    n,k = map(int, stdin.readline().rstrip().split())
    H = list(map(int, stdin.readline().rstrip().split()))
    #numbers = [[int(c) for c in l.strip().split()] for l in sys.stdin]
    #word = [stdin.readline().rstrip() for _ in range(n)]
    #number = [[int(c) for c in stdin.readline().rstrip()] for _ in range(n)]
    #zeros = [[0] * w for i in range(h)]
    H.sort()
    if n <= k:
        print(0)
        exit()

    for i in range(k):
        H.pop(-1)

    print(sum(H))

if __name__ == '__main__':
    solve()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,A=map(int,input().split())
B=sorted(list(map(int,input().split())))
for j in range(A):
    if B!=[]: B.pop()
print(sum(B))

Submission status: Accepted

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	C
# CreatedDate:  2020-06-27 15:37:37 +0900
# LastModified: 2020-06-27 15:43:18 +0900
#


import os
import sys
# import numpy as np
# import pandas as pd


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



if __name__ == "__main__":
    main()

Submission status: Accepted

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

A.sort()

SUM = 0
for i in range(N - K):
    SUM += A[i]

print(SUM)

Submission status: Accepted

Solution code:
N,K =list(map(int,input().split()))
H =sorted(list(map(int,input().split())))
print(sum(H[:-1*K]) if K > 0 else 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>n:
    k=n
for i in range(k):
    h[i]=0
print(sum(h))

Submission status: Accepted

Solution code:
import sys

n, k = map(int, input().split())
hn = sorted(list(map(int, sys.stdin.readline().split())), reverse=True)

ans = sum(hn[k:])
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


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

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

Submission status: Accepted

Solution code:
import heapq
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())
Hs = list(map(int, input().split()))

Hs.sort(reverse=True)

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

M = list(map(int,input().split()))
M =sorted(M,reverse=True)

print(sum(M[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)
  exit(0)

for i in range(1, k+1):
  h[-i] = 0
print(sum(h))

Submission status: Accepted

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

Submission status: Accepted

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

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

print(sum_at)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

H = sorted(H, reverse = True)

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

print(ans)

Submission status: Accepted

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

hl.sort(reverse=True)

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

rem_hl = hl[k:]
rem_sum = sum(rem_hl)
print(rem_sum)

Submission status: Accepted

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

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

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:

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