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 = [int(i) for i in input().split()]
h = [int(i) for i in input().split()]

h = sorted(h)
h[-1:-k-1:-1] = [0,] * min(n, k)

print(sum(h))

Submission status: Accepted

Solution code:
import heapq

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

h = list(map(lambda x:-x,h))

if n<=k:
    print("0")
else:
    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 = 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 = (int(i) for i in input().split())
h = [int(i) for i in input().split()]
sorted_h = sorted(h)
if n <= k:
    ans = 0
else:
    ans = sum(sorted_h[0:n-k])
print(ans)

Submission status: Accepted

Solution code:
feneck = input().split()
H = input().split()
H_i = [int(h) for h in H]

N = int(feneck[0])
K = int(feneck[1])

list.sort(H_i, reverse=True)

if K < len(H_i):
  sum = 0
  H_i = H_i[K:]
  for hp in H_i:
    hp = int(hp)
    sum += hp
  print(sum)
else:
  print(0)

Submission status: Accepted

Solution code:
line1 = input()
line2 = input()
n, k = line1.split(" ")
h = line2.split(" ")
h = [int(i) for i in h]
h.sort()
if int(k) >= int(n):
    print(0)
else:
    for i in range(int(k)):
        h.pop(-1)
    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[:-K]))
else:
    print(sum(H))

Submission status: Accepted

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

print(sum(h[k:]))

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
arr=list(map(int,input().split()))
arr=sorted(arr,reverse=True)
for i in range(min(n,k)):
  arr[i]=0
print(sum(arr))

Submission status: Accepted

Solution code:
h, n = list(map(int,(input().split())))
a = list(map(int,(input().split())))
import sys
sys.setrecursionlimit(10 ** 9) #再帰用

a.sort(reverse=True)

if h >= n and n !=0 :
  a = a[n:]
  ans = sum(a)
elif n ==0:
  ans = sum(a)
else:
  ans = 0
  
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

h = sorted(h, reverse=True)
del h[0:k]

attack_total = sum(h)

print(attack_total)

Submission status: Accepted

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

mon = list(map(int,input().split()))
mon.sort()
    
count = 0

if N > K:
  for i in range(N-K):
    count += mon[i]
else:
  pass
    

print(count)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
h=list(map(int,input().split()))
h.sort(reverse=True)
# for _ in range(min(k,n)):
#     h.pop(0)
print(sum(h[min(k,n):]))

Submission status: Accepted

Solution code:
from fractions import gcd
# from datetime import date, timedelta
# from heapq import *
import heapq
import math
from collections import defaultdict, Counter, deque
from bisect import *
import itertools
import fractions
import sys
sys.setrecursionlimit(10 ** 7)
MOD = 10 ** 9 + 7
# input = sys.stdin.readline


def lcm(a, b):
    return a * b / fractions.gcd(a, b)


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors


def factorize(n):
    fct = []  # prime factor
    b, e = 2, 0  # base, exponent
    while b * b <= n:
        while n % b == 0:
            n = n // b
            e = e + 1
        if e > 0:
            fct.append((b, e))
        b, e = b + 1, 0
    if n > 1:
        fct.append((n, 1))
    return fct


def is_prime(n):
    if n == 1:
        return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True


def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]

def modpow(a, n, mod):
    res = 1
    while n > 0:
        if n & 1:
            res = res * a % mod
        a = a * a % mod
        n >>= 1
    return res


def modinv(a, mod):
    return modpow(a, mod - 2, mod)


def cnk(a, b):
    MOD = 10**9+7
    ret = 1
    for i in range(b):
        ret *= (a-i)
        ret %= MOD
        ret = ret * modinv(i+1, MOD) % MOD
    return ret


class UnionFind:
    def __init__(self, n):
        self.sz = [-1 for i in range(n)]

    # 検索
    def find(self, x):
        if self.sz[x] < 0:
            return x
        else:
            self.sz[x] = self.find(self.sz[x])
            return self.sz[x]

    # 併合
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return False
        if self.sz[x] > self.sz[y]:
            x, y = y, x
        self.sz[x] += self.sz[y]
        self.sz[y] = x

    # 同じ集合に属するか判定
    def same(self, x, y):
        return self.find(x) == self.find(y)

    # xが含まれている集合のサイズを求める
    def size(self, x):
        return -self.sz[self.find(x)]


def main():
    n,k = map(int, input().split())
    a = list(map(int, input().split()))
    ans = 0
    if n <= k:
        print(0)
        exit()
    a.sort()
    for i in range(k):
        a[-i - 1] = 0
    ans += sum(a)
    print(ans)




            


    




    


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
x = [int(i) for i in input().split(" ")]
s = x[1]
m = [int(i) for i in input().split(" ")]
if s == 0:
  print(sum(m))
else:
  m = sorted(m)[0:-s:1]
  print(sum(m))

Submission status: Accepted

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

list.sort(h, reverse=True)
if k > len(h):
    print(0)
else:
    re_en = h[k:]
    print(sum(re_en))

Submission status: Accepted

Solution code:
x=input().split()
n=int(x[0])
k=int(x[1])
x=input().split()
h=[]
for i in range(len(x)):
  h.append(int(x[i]))
h=sorted(h)
if k<=n:
  print(sum(h[0:n-k]))
else:
  print(0)

Submission status: Accepted

Solution code:
def get(text,n):
    ans = [""]*n
    i = 0
    for x in text:
        if x==" ":
            i = i + 1
        ans[i] = ans[i]+x
    return ans

nk = input()
N = int(get(nk,2)[0])
K = int(get(nk,2)[1])

H = get(input(),N)
for i in range(N):
    H[i]= int(H[i])

H.sort()

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

print(s)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
import math
import itertools as it
def i():return int(sys.stdin.readline().replace("\n",""))
def i2():return map(int,sys.stdin.readline().replace("\n","").split())
def s():return str(sys.stdin.readline().replace("\n",""))
def l():return list(sys.stdin.readline().replace("\n",""))
def intl():return [int(k) for k in sys.stdin.readline().replace("\n","").split()]
def lx():return list(map(lambda x:int(x)*-1,sys.stdin.readline().replace("\n","").split()))
def t():return tuple(map(int,sys.stdin.readline().replace("\n","").split()))

if __name__ == "__main__":pass
n, k = i2()
h = intl()
h.sort()
cnt = 0
if n > k:
    for i in range(n-k):
        cnt += h[i]
    print(cnt)
else:
    print(0)

Submission status: Accepted

Solution code:
import sys
import math
import itertools as it
def i():return int(sys.stdin.readline().replace("\n",""))
def i2():return map(int,sys.stdin.readline().replace("\n","").split())
def s():return str(sys.stdin.readline().replace("\n",""))
def l():return list(sys.stdin.readline().replace("\n",""))
def intl():return [int(k) for k in sys.stdin.readline().replace("\n","").split()]
def lx():return list(map(lambda x:int(x)*-1,sys.stdin.readline().replace("\n","").split()))
def t():return tuple(map(int,sys.stdin.readline().replace("\n","").split()))

if __name__ == "__main__":pass
n, k = i2()
h = intl()
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 = list(map(int, input().split()))
h.sort()

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

Submission status: Accepted

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

A.sort()
if N > K:
  for i in range(K):
    A.pop()
  print(sum(A))
else:
  print("0")

Submission status: Accepted

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

print(sum(HL[K:]))

Submission status: Accepted

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

li=sorted(li,reverse=True)
sum_=sum(li)
for i in range(m):
  if i>=len(li):
    break
  sum_-=li[i]
print(sum_)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import numpy as np

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

H = np.sort(np.array(H))[::-1]
H = H[min(K, H.shape[0]):]

print(np.sum(H))

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
def attack(n, k, H):
  H.sort(reverse = True)
  sum = 0
  for i in range(k, n):
    sum += H[i]
  return sum

n, k = map(int, input().split())
H = list(map(int, input().split()))
print(attack(n, k, H))

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
H = sorted(map(int, input().split()))
if N < K:
    K = N
for _ in range(K):
    H.pop(-1)
print(sum(H))

Submission status: Accepted

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

import sys

def main():
    n, k = [int(x) for x in sys.stdin.readline().split()]
    hs = [int(x) for x in sys.stdin.readline().split()]

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

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N, K = [int(i) for i in input().split()]
H_list = [int(i) for i in input().split()]
H_list.sort(reverse=True)
print(sum(H_list[K:]))

Submission status: Accepted

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

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

print(HAS-HHA)

Submission status: Accepted

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

Submission status: Accepted

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

h = sorted(h, reverse=True)

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

A = list(reversed(sorted(A)))[k:]

print(sum(A))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import numpy as np
from sys import stdin
from copy import deepcopy
from functools import reduce
from fractions import gcd
import math
import itertools
from collections import Counter
from itertools import chain  ##list(chain.from_iterable(l)) ##flatten
from heapq import heappush, heappop

"""
N = int(input())
A, B = map(int,input().split())
A = list(map(int,input().split())) ## 横一列
A = [int(input()) for _ in range(N)] ## 縦一列
lst = [list(map(int,input().split())) for i in range(M)] ## 二次元
"""

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

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

H = sorted(H, 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()))

if K==0:
  print(sum(H))
  exit()
  
H.sort()
del H[-K:]
print(sum(H))

Submission status: Accepted

Solution code:
n,k,*a=map(int,open(0).read().split())
a.sort()
a+=[0]
print(sum(a[:~k]))

Submission status: Accepted

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

Nlife = sorted(life, reverse=True)


if K >= 1:
  del Nlife[:K]
  

answer = sum(Nlife)

print(answer)

Submission status: Accepted

Solution code:
special_moves = input().split(" ")

_, special_moves = int(special_moves [0]), int(special_moves [1])

health= input().split(" ")
health= [int(h) for h in health]
health.sort(reverse=True)
print(sum(health[special_moves:]))

Submission status: Accepted

Solution code:
inputs = input().split(" ")

monsters_num, special_moves = int(inputs[0]), int(inputs[1])

health_inp = input().split(" ")
monsters_health = [int(h) for h in health_inp]
monsters_health.sort(reverse=True)
print(sum(monsters_health[special_moves:]))

Submission status: Accepted

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

if n<k :
    print(0)
else:
    print(sum(sorted(h)[:n-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())
List=list(map(int,input().split()))
if len(List)<= k:
    print(0)
else:
    newList = sorted(List, reverse=True)
    # print(newList)
    print(sum(newList[k:]))

Submission status: Accepted

Solution code:
import math

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

h = sorted(H)
i = len(H)-K

if K <= N: 
	H_count = sum(h[:i])
	print(H_count)
else:
	print(0)

Submission status: Accepted

Solution code:
a,b=map(int,input().split())
c=list(map(int,input().split()))
c.sort()
e=0
i=0
while i<a-b:
    e=e+c[i]
    i=i+1
print(e)

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
listA=[]

for i in range(2):
    try:
        listA.append(list(map(int, input().split())))
        #listA<-[1,2,2,3,1]
        #print(listA)
        #ここに逐次処理を書けばいいと思う。
    except:
        break;
        #または、quit(),os.exit()をして止める。

N=(listA[0])[0]
K=(listA[0])[1]
listf=listA[1]

listf.sort()

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys


def InS(): return input()


def InL(): return list(map(int, input().split()))


def InI(): return int(input())


N, K = InL()
H = InL()
H.sort()

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

Submission status: Accepted

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

print(sum(h_list[k:]))

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
if K < N:
    ans = sum(A[: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()
ans = 0

if n <= k:
    h.clear()
else:
    for i in range(k):
            h.pop(-1)

print(sum(h))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
enemy_count, skills = map(int,input().split())
enemies = list(map(int,input().split()))
enemies.sort()
if skills != 0:del enemies[-1*skills:]
print("%d"%sum(enemies))

Submission status: Accepted

Solution code:
n,k = map(int,input().split())
h = sorted(list(map(int,input().split())))#小から右へ
ans = 0
if n-k-1 >= 0:
    print(sum(h[:n-k]))
    exit()
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

sum = 0
for i in range(K, len(H)):
    sum += H[i]

print(sum)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

print(sum)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
query=[int(x) for x in input().split()]
N = query[0]
K = query[1]
l=[int(x) for x in input().split()]
l.sort(reverse=True)
sum=0
for i in range(K,N):
    if i<N:
        sum=sum+l[i]
print(sum)

Submission status: Accepted

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

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:
def attack(h, k, arr):
    arr.sort()
    if h - k > 0:
        return sum(arr[0:h-k])
    else:
        return 0

if __name__ == "__main__":
    h, k = map(int, input().split())
    arr = list(map(int,input().split()))
    print(attack(h, k, arr))

Submission status: Accepted

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

answer = 0
if N > K:
    H.sort()
    for i in range(N - K):
        answer += H[i]

print(answer)

Submission status: Accepted

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

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

Submission status: Accepted

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


h.sort()


i=1
try:
    while i<=k:
       h[-i]=0
       i+=1
except:
    pass


i=0
ans=0
while i<n:
    ans+=h[i]
    i+=1
print(ans)

Submission status: Accepted

Solution code:
nk = input().strip().split()
k = int(nk[1])
h = [int(i) for i in input().strip().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())))
if N>K:
  H=H[0:N-K]
  print(sum(H))
else:
  print(0)

Submission status: Accepted

Solution code:
import itertools
import sys
import math
import numpy as np
from collections import deque
from itertools import combinations
from functools import lru_cache
sys.setrecursionlimit(10**9)


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

    target_count = len(H) - K
    sum = 0
    for i in range(target_count):
        sum += H_sorted[i]

    print(sum )


if __name__ == "__main__":
  main()

Submission status: Accepted

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

H.sort()

count = 0

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

Submission status: Accepted

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

H.sort()

if N <= K:
    min = 0
else:
    min = 0
    left = N - K
    for i in range(left):
        min += H[i]

print(min)

Submission status: Accepted

Solution code:
# -*- coding:utf-8 -*-
n,k = map(int, input().split())
h = []
count = 0

for i in map(int, input().split()):
  h.append(i)

hr = sorted(h, reverse=True)

for l in range(n):
  if l >= k:
    count += hr[l]
print(count)

Submission status: Accepted

Solution code:
# coding: utf-8
# submission # - User: herp_sy
# https://atcoder.jp/contests/
#
# lang: Python3 (3.4.3)

import math
import statistics
import numpy as np
import queue

h,k = map(int, input().split())
h = np.array(sorted(list(int(i) for i in input().split()), \
      reverse = True))

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n,k = map(int,input().split())
s = list(map(int,input().split()))
s.sort()
if k == 0:
  print(sum(s))
elif n >= k:
  del s[-k:]
  print(sum(s))
else:
  print(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()))
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)
new_H = H[K:]
result = sum(new_H)

print(result)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n, k = (int(z) for z in input().split())
a = [int(z) for z in input().split()]
a.sort()
sm = 0
for i in range(n - k):
  sm += a[i]
print(sm)

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

print(ans)

Submission status: Accepted

Solution code:
# coding: utf-8

fennec = input().split(" ")
N = int(fennec[0])
K = int(fennec[1])
enemys = input().split(" ")
enemys_int = [int(s) for s in enemys]
enemys_int.sort()
ans = 0
if K < N:
    if K == 0:
        for i in enemys_int:
            ans += int(i)
        print(ans)
    else:
        del enemys_int[-K:]
        for i in enemys_int:
            ans += int(i)
        print(ans)
else:
	print("0")

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

if K >= N:
    print(0)
else:
    s = 0
    for i in range(0,N-K):
        s = s + J[i]
    print(s)

Submission status: Accepted

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

Submission status: Accepted

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

h2 = sorted(h,reverse=True)

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

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)

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

Submission status: Accepted

Solution code:
enemy_num, dethblow_num, *enemy_hp = map(int, open(0).read().split())

if enemy_num >= dethblow_num:
    enemy_hp.sort(reverse=True)
    del enemy_hp[:dethblow_num]
else:
    enemy_hp.clear()
    enemy_hp = [0]
    
print(sum(enemy_hp))

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N,K = map(int,input().split())
H = [int(i) for i in 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()))

H.sort()
H.reverse()

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:
import sys

I = list(map(int, input().split()))
H_i = list(map(int,input().split()))
H_i = [i for i in H_i if 1 <= i and i <= 10**9]
N = I[0] # Monster数
K = I[1] # 必殺技回数

if not 0 <= K or not K <= 2*10**5 or not 1 <= N or not N <= 2*10**5:
    print("error")
    sys.exit()

H_i = sorted(H_i, reverse=True) # 降順ソート
H_i = H_i[K:]
ans = sum(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:
H, K = map(int, input().split())
array = list(map(int, input().split()))
A = sorted(array, reverse=True)
del A[0:K]
print(sum(A))

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()
    s=0
    for i in range(0,N-K):
        s=s+H[i]
    print(s)

Submission status: Accepted

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

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

if n<=k:
    number = 0
elif 0<k<n:
    h_lst.sort()
    number = sum(h_lst)-sum(h_lst[-k:])
elif k==0:
    number = sum(h_lst)

print(number)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
	x = [int(i) for i in input().split()]
	y = [int(i) for i in input().split()]
	y.sort()
	if (x[1]!=0):
		z = y[:-x[1]]
	else:
		z = y
	print(sum(z))
if __name__== "__main__":
	main()

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(int(1e6))

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

H.sort()
n = len(H) - K
if n > 0:
    ans = sum(H[:n])
else:
    ans = 0
print(ans)