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:
# coding:utf-8

import sys
import math
import time
import numpy as np
import collections
from collections import deque
import queue
import copy

# 最大公約数
def gcd(m,n):
  x = max(m,n)
  y = min(m,n)
  if x%y == 0:
    return y
  else:
    while x%y != 0:
      z = x%y
      x = y
      y = z
    else:
      return z

# 幅優先探索(BFS)でスタート座標(x, y)からの最大距離返す
def bfs(SS, x, y, H, W):#入力(座標系(迷路), x, y, xの端, yの端)
  x_next = [0, 0, -1, 1]
  y_next = [1, -1, 0, 0]
  tempx = x
  tempy = y
  mlength = 0
  q = deque()
  xytuple = (x, y, 0)
  q.append(xytuple)


  while q:
    xytuple = q.popleft()
    SS[xytuple[0]][xytuple[1]] = "x" #探索した場所は探索できないようにする
    for i in range(4): #このforで上下左右を調べてる
      tempx = xytuple[0] + x_next[i]
      tempy = xytuple[1] + y_next[i]
      #print(tempx, tempy, xytuple[2])
      #print(S)
      if(0 <= tempx and tempx < H and 0 <= tempy and tempy < W and SS[tempx][tempy] == "."):
        temptuple = (tempx, tempy, xytuple[2]+1)
        SS[temptuple[0]][temptuple[1]] = "x" #探索した場所は探索できないようにする
        mlength = max(mlength, xytuple[2] +1)
        q.append(temptuple)
      #print(q)
  return mlength

def brick(a,n,m,N):#ABC 148
  #n番目以降にmがあるか調べる
  if not m in a[n:]:
    print(N-(m-1))
  else:
    #b = copy.deepcopy(a)
    brick(a,a[n:].index(m),m+1,N)

#X = str(input()).split()
#a = [int(x) for x in input().split()]
HA = str(input()).split()
H = int(HA[0])
A = int(HA[1])
a = [int(x) for x in input().split()]

count = 0

if(H<A):
    print(0)
else:
    a.sort()
    for i in range(H-A):
        count += a[i]
    print(count)

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
Hs = list(map(int, input().split()))
Hs = sorted(Hs, reverse = True)
ans = 0
for h in Hs[k:]:
    ans+=h
print(ans)

Submission status: Accepted

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

H.sort(reverse = True)
if S >= N:
    S = N

print(sum(H[S:]))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
H_list_ = input().split()
H_list = [int(s) for s in H_list_]

sorted_H_list = sorted(H_list, reverse=True)

print(sum(sorted_H_list[K:]))

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
H = list(sorted(list(map(int, input().split())), reverse=True))
ans = 0
for h in H[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)
i = 0
kaisuu = 0


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

j = i

for j in range(j, n):
    kaisuu = kaisuu + h[j]

print(kaisuu)

Submission status: Accepted

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

h.sort()
if len(h) <= k:
    print(0)
    exit()
else:
    t = sum(h[0:len(h)-k])
    print(t)

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:
    for _ in range(K):
        H.pop()
    print(sum(H))

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N, K = map(int, input().split(' '))
H = list(map(int, input().split(' ')))
H.sort()
if N <= K: K = N
for k in range(K):
    H.pop()
print(sum(H))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python
from __future__ import division, print_function

import os
import sys
from io import BytesIO, IOBase

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip


def main():
    n, k = map(int, input().split())
    h = [int(hi) for hi in input().split()]
    h.sort()
    for _ in range(k):
        if h:
            h.pop()

    print(sum(h))


# region fastio

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()


if sys.version_info[0] < 3:
    sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
else:
    sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)

input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Hs = sorted(H)

if K>=N :
  K=N

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n,k,*h=map(int,open(0).read().split())
h.sort()
for i in range(k):
  if len(h)!=0:
    h.pop()
print(sum(h))

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(N):
  if (i < K):
    continue
  else :
    sum = sum + H[i]
    
print(sum)

Submission status: Accepted

Solution code:
from math import ceil

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

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

Submission status: Accepted

Solution code:
N,K = map(int,input().split()) #K = super attack!!
Monsters = [_ for _ in map(int,input().split())]
res = 0
#一番体力の多いモンスターから、Kで殺していく。あとは一足すだけ。
Monsters.sort(reverse = True) #多い順
res += sum(Monsters[K:N+1])
print(res)

Submission status: Accepted

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


def solve(N: int, K: int, H: "List[int]"):
    print(sum(sorted(H, reverse=True)[K:len(H)]))
    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:
# coding: utf-8

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

Submission status: Accepted

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

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

Submission status: Accepted

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

k = N if N <= K else K
T = A[k:]
print(sum(T))

Submission status: Accepted

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

H.sort(reverse=True)

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import os
import statistics
def quickSort(arr):
   # 配列のメジアンより小さい要素を集めた配列
    left = []

    # 配列のメジアンより大きい要素を集めた配列
    right = []

    # 再帰の停止条件
    # 再帰的に配列を分割した後の、要素数が1以下になったら停止する
    if len(arr) <= 1:
        return arr

    # 配列の中央値(メジアン)を取得する
    median = int(statistics.median(arr))

    # 配列内に含まれる中央値の個数を数えるための変数
    medianFlg = 0

    for element in arr:
        # 配列の要素(element)が中央値より小さいので、
        # 配列leftに値を格納する
        if element < median:
            left.append(element)
        # 配列の要素(element)が中央値より大きいので、
        # 配列rightに値を格納する
        elif element > median:
            right.append(element)
        else:
        # elementが配列の中央値の場合は、
        # 返り値に加える中央値の個数分だけ、フラグに+1し続ける
            medianFlg += 1

    # print(left)
    # print(right)

    # 配列left、配列right毎に再帰を行い
    # 配列を小さな配列に区切る
    left = quickSort(left)
    right = quickSort(right)

    # 配列left、中央値の[median]、配列rightを結合したものを返す
    return left + [median] * medianFlg + right

N,K=map(int,input().split())
h=map(int,input().split())
H=list(h)
M=quickSort(H)
c=0
if N-K==0:
 print(c)
else:
 for i in range(N-K):
  c+=M[i]
 print(c)

Submission status: Accepted

Solution code:
R = lambda: map(int, input().split())
n, k = R()
print(sum(sorted(R())[:n - min(k,n)]))

Submission status: Accepted

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

if k >= len(h):
    print("0")
    exit(0)

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

Submission status: Accepted

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

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

Submission status: Accepted

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

if len(H) <= K:
    print(0)
else:
    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)
del h[:k]
print(int(sum(h)))

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

# H を高い順にソート
# 上からK個削除
# SUM

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

print(s)

Submission status: Accepted

Solution code:
def values():
  return [int(x) for x in input().split()]

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

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

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


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

stdin = sys.stdin

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))

n,k = nm()
h = nl()
h.sort(reverse=True)
print(sum(h[k:] + [0]))

Submission status: Accepted

Solution code:
import numpy as np

E, H = list(map(int, input().split()))
A = np.array(list(map(int, input().split())))

if H>=E:
  print("0")
else:
  A = np.sort(A)
  if H>0:
    Ans = A[:-H].sum()
  else:
    Ans = A[:].sum()
  print(Ans)

Submission status: Accepted

Solution code:
import numpy as np

if __name__ == "__main__":
  _n, _k = map(int, input().split())
  h_list = np.array([int(i) for i in input().split()])
  if _n <= _k:
    print("0")
    exit(0)

  h_list = np.sort(h_list)[::-1]
  h_list = h_list[_k:]
  sum = np.sum(h_list)
  print(sum)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#! /usr/bin/env python
# -*- coding: utf-8 -*-

import pdb
import sys
sys.setrecursionlimit(10**7)
F = sys.stdin

N,K = map(int,F.readline().split())
H_list = list(map(int,F.readline().rstrip().split()))
attack = 0

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

H_list.sort(reverse=True)

for i in range(N):
    if i >= K:
        attack += H_list[i]


print(attack)

Submission status: Accepted

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

H = sorted(H, reverse=True)

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

Submission status: Accepted

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

h = [int(h) for h in input().split()]
h.sort()  # 敵の体力が小さい順に並べる

if k:
  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 K>0:
  H_total = sorted(H)[:-K]
else:
  H_total = sorted(H)
H_total = sum(H_total)

ans = H_total

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import numpy as np


DEBUG = True
dprint = print if DEBUG else lambda *x : x

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

if K == 0:
    print(sum(H))
elif K >= len(H):
    print(0)
else:
    H.sort(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 len(a)<k:
    print(0)
else:
    ans=0
    for i in range(0,len(a)-k):
        ans=ans+a[i]
    print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

H = sorted(H,reverse=True)

del H[:nk[1]]

import numpy as np
print(int(np.array(H).sum()))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, k = [int(item) for item in input().split()]
H_list = [int(item) for item in input().split()]
H_list.sort()

if N <= k:
    print(0)
else:
    mob_num = N - k
    print(sum(H_list[:mob_num]))

Submission status: Accepted

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

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

Submission status: Accepted

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

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)

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

Submission status: Accepted

Solution code:
import math
import calendar
import fractions
import itertools

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

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

Submission status: Accepted

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

ls.sort()

if k == 0:
    print(sum(ls))
else:
    print(sum(ls[:(-1) * k]))

Submission status: Accepted

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

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

else:
    H_s = sorted(H)
    print(sum(H_s[:len(H)-K]))

Submission status: Accepted

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

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:
import math 
n, k = map(int, input().split())
yes = 'Yes'
no = 'No'
h = list( map(int, input().split()))
h = sorted(h, reverse=True)
if len(h) <= k:
  print(0)
else:
  print(sum(h[k:]))

Submission status: Accepted

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

if n <=k:
    print(0)

else:
    H.sort()
    fin = sum(H[0:n-k])
    print(fin)

Submission status: Accepted

Solution code:
[n,k] = [int(x) for x in input().split()]
h=[int(x) for x in input().split()]
h.sort(reverse = True)
sum=0
for i in range(n-k):
	sum += h[k+i]
print(sum)

Submission status: Accepted

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

def sum(list,k):#最初からk個までの和
    s = 0
    for i in range(len(list)-k):
        s = s+ list[i]
    return s


hunter_list.sort()

print(sum(hunter_list,k))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

ld = sorted(l, reverse=True)

print(sum(ld[K:]))

Submission status: Accepted

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

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

Submission status: Accepted

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

H.sort(reverse=True)

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

Submission status: Accepted

Solution code:
import numpy as np

N, K = map(int, input().split())
H = list(map(int, input().split()))
H = np.array(H)
H = np.sort(H)[::-1]

H[:K] = 0

print(np.sum(H))

Submission status: Accepted

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

E=sorted(H,reverse=True)

answer=0

if N<=K:
    print(0)
else:
    for i in range(N-K):
        answer+=E[K+i]
    print(answer)

Submission status: Accepted

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

h_sort = sorted(h)

if k>=len(h):
  print(0)
else:
  teki = len(h) - k
  
  h_teki = h_sort[:teki]
  print(sum(h_teki))

Submission status: Accepted

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

H.sort(reverse=True)

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

H_list_sort = sorted(H_list)


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

Submission status: Accepted

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

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

Submission status: Accepted

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

h.sort()


total = 0

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


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

print(total)

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:
        h.pop()
print(sum(h))

Submission status: Accepted

Solution code:
first = input().split(' ')
skills_count = int(first[1])

second = input().split(' ')
healths = [int(s) for s in second]
healths.sort(reverse=True)

print(sum(healths[skills_count:]))

Submission status: Accepted

Solution code:
def read_int_n():
    return list(map(int, input().split()))
hn=read_int_n()
n=hn[0]
k=hn[1]
h=read_int_n()
H=sorted(h,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()))
size=len(H)
if N<=K:
  ret=0
else: 
  H.sort()
  ret=max(0, sum(H)-sum(H[size-K:]))

print( ret )

Submission status: Accepted

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

del h[0:k]

print(sum(h))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,K = map(int,input().split())
Hlist = list(map(int,input().split()))
Hlist.sort()
if K>=N:
    print(0)
else:
    for i in range(K):
        Hlist.pop()
    print(sum(Hlist))

Submission status: Accepted

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

H.sort(reverse=True)

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

Submission status: Accepted

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

t = min(n, k)
ans = sum(h[0:(n-t)])
print(ans)

Submission status: Accepted

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

Max=sum(A)
A.sort(reverse=True)
min=sum(A[:N])
print(Max-min)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math

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

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

Submission status: Accepted

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

if K >= N:
  print(0)
else:
  A.sort()
  A = A[::-1]
  answer = sum(A[K:])
  print(answer)

Submission status: Accepted

Solution code:

class Solution:
    def solve(self, H, k, monsters):
        monsters.sort(reverse=True)

        return sum(monsters[k:])


sol = Solution()

[H, k] = list(map(int, input().strip().split()))
monsters = list(map(int, input().strip().split()))

print(sol.solve(H, k, monsters))

Submission status: Accepted

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

h.sort(reverse=True)
for i in range(k):
    if i >= n:
        break
    h[i]=0
hsum = sum(h)
print(hsum)

Submission status: Accepted

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

H.sort(reverse=True)

K = min(K, len(H))
HH = H[K:]

print(sum(HH))

Submission status: Accepted

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

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

H.sort(reverse=True)

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

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

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

cutList = hList[:n-k]
print(sum(cutList))

Submission status: Accepted

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


def main():
    n, k = map(int, input().split())

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

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

Submission status: Accepted

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

Submission status: Accepted

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

H = sorted(H, reverse=True)[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:
def main():
    N,K = map(int, input().split())
    H = list(map(int, input().split()))
    H = sorted(H, reverse=True)
    if(len(H) < K):
        res = 0
    else:
        res = sum(H[K:])
    print(res)

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import sys
 
if sys.platform =='ios':
    sys.stdin=open('input_file.txt')
 
 
H,A=map(int,input().split())

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

li=sorted(l)

for _ in range(min(H,A)):
	li.pop()
	
print(sum(li))