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: Runtime Error

Solution code:
n,k = map(int,input().split())
mlist = list(map(int,input().split()))
sh = 0
kaisuu = at = 0

while n >0:
    n -= 1
    sh = sh+mlist[n]

while sh >= 0:
    while k > 0:
        at=max(mlist)
        mlist.remove(at)
        k -= 1
        sh = sh -at
        if sh <= 0:
            break
    
    else:
        kaisuu = kaisuu + sh
        break

print(kaisuu)

Submission status: Runtime Error

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: Runtime Error

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

h = sorted(h)
l = len(h)
for i in range(l-k,l):
  h[i] = 0
  
result = 0  
for j in range(0, l):
  result = result + h[j]
print(result)

Submission status: Runtime Error

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

h = sorted(h)
l = len(h)
if k != 0:
  for i in range(l-k,l):
    h[i] = 0
  
result = 0  
for j in range(0, l):
  result = result + h[j]
print(h)
print(result)

Submission status: Runtime Error

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

h = sorted(h)
l = len(h)
for i in range(l-k,l):
  h[i] = 0
  
result = sum(h)
print(result)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

healths = input().split()
res = 0

healths = healths.sort()
for i in range(n):
    if i >= n-k:
        break
    res = res + int(healths[i])

print(res)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

for i in range(K):
  H.pop()

print(sum(H))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n, k = map(int, input().split())
h = list(map(int, input().split()))
count = 0
 
for _ in range(n-k)
  count += min(h)
  h.remove(min(h))
  
print(count)

Submission status: Runtime Error

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

while len(h) > 0:
  if k > 0:
    k -= 1
    h.remove(max(h))
    continue
  else:
    for i in h:
      count += i
      
print(count)

Submission status: Runtime Error

Solution code:
from sys import stdin

x,y = [long(x) for x in stdin.readline().rstrip().split()]
li = list(map(long,stdin.readline().rstrip().split()))

z = 0
if(x<y):
    print(z)

else:
    li = li.sort(reverse=True)
    del li[0:y-1]

    z = 0
    for i in li:
        z = z + i

    print(z)

Submission status: Runtime Error

Solution code:
#入力
N, K = map(int, input().split())
li = list(map(int,input().split()))
list.sort(li, reverse = True)

#出力
for i in range(K):
    li[i] = 0

print(sum(li))

Submission status: Runtime Error

Solution code:
import numpy as np
from numba import jit

@jit
def do():
    data = np.array(input().split(" "), dtype="int64")
    life = np.array(input().split(" "), dtype="int64")
    monsters = data[0]
    smash = data[1]
    if smash == 0:
        print(np.sum(life))
    elif smash >= monsters:
        print(0)
    else:
        a = np.sort(life)[-smash]
        leftover = np.where(life < a, life, 0)
        print(np.sum(leftover))

do()

Submission status: Runtime Error

Solution code:
import numpy as np
from numba import jit

@jit
def do():
    data = np.array(input().split(" "), dtype="int64")
    life = np.array(input().split(" "), dtype="int64")
    monsters = data[0]
    smash = data[1]
    if smash == 0:
        print(np.sum(life))
    elif smash >= monsters:
        print(0)
    else:
        a = np.sort(life)[-smash]
        leftover = np.where(life < a, life, 0)
        print(np.sum(leftover))

do()

Submission status: Runtime Error

Solution code:
import numpy as np
from numba import jit
  
data = np.array(input().split(" "), dtype="int")
life = np.array(input().split(" "), dtype="int")
@jit
def calculation(data, life):
    monsters = data[0]
    smash = data[1]
    a = np.sort(life)
    if smash >= len(a):
        print(0)
    elif smash == 0:
        print(np.sum(a))
    else:
        leftover = np.where(a[-smash] > a, a, 0)
        print(np.sum(leftover))

calculation(data, life)

Submission status: Runtime Error

Solution code:
import numpy as np
from numba import jit
  
data = np.array(input().split(" "), dtype="int")
life = np.array(input().split(" "), dtype="int")
@jit
def calculation(data, life):
    monsters = data[0]
    smash = data[1]
    a = np.sort(life)
    leftover = np.where(a[-smash] > a, a, 0)
    print(np.sum(leftover))

calculation(data, life)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

if n <= k:
  print('0')
else:
  print(sum(h_arr[k:]))

Submission status: Runtime Error

Solution code:
src/contest/abc/abc153/c.py

Submission status: Runtime Error

Solution code:
S_nk = input().split(" ") #標準入力（N, K）
S_h = input().split(" ") #標準入力（Hi）

N = int(S_nk[0]) #モンスターの種類
K = int(S_nk[1]) #必殺技の制限回数
H = [] #モンスターのヒットポイント
for i in range(N):
  H.append(int(S_h[i]))

#ヒットポイントの大きい順にソート
H.sort(reverse=True)

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

print(sum(H))

Submission status: Runtime Error

Solution code:
N,K = map(int,input().split(" "))
H = list(map(int,input().split(" ")))
H = sorted(H,reverse = True)
Flag = False
if len(H)<=(K):
        H.clear()
        Flag = True
        print("0")
        
if Flag == False:
    for i in range(K):
        H.remove(H[i])
    print(sum(H))

Submission status: Runtime Error

Solution code:
N,K = map(int,input().split(" "))
H = list(map(int,input().split(" ")))
H = sorted(H,reverse = True)
for i in range(K):
    H.remove(H[i])
sum_ = sum(H)
pint(sum)

Submission status: Runtime Error

Solution code:
def main():
	N,K = map(int,input().split())
	H = [int(h) for h in input().split()]
	H = sorted(H,reverse=True)
	for i in range(K):
		H[i] = 0
	print(sum(H))
if __name__ == '__main__':
	main()

Submission status: Runtime Error

Solution code:
myinput = input()
myinput_H = input()
mylist = list(map(int, myinput.split(" ")))
N = int(mylist[0])
K = int(mylist[1])
list_H = list(map(int, myinput_H.split(" ")))
for i in range(K):
    list_H.remove(max(list_H))
sum = sum(list_H)
print(sum)

Submission status: Runtime Error

Solution code:
N, K = [int(_) for _ in input().split()]
H = [int(_) for _ in input().split()]
list_H = sorted(H, reverse=True)
for k in range(K):
    list_H.pop(k)
attack = 0
for i in H:
    attack += i
print(attack)

Submission status: Runtime Error

Solution code:
temp = input().split(' ')
monter_count = int(temp[0])
kill_count = int(temp[1])

temp = input().split(' ')
# 数値の配列に変換
temp = [int(s) for s in temp]
# 体力の多い順にソート
temp.sort(reverse=True)
del(temp[0:monter_count])
print(temp.sum())

Submission status: Runtime Error

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

attack = 0
for i, hp in enumurate(reversed(hp_list)):
  if i < k:
    continue
  attack += hp
print(attack)

Submission status: Runtime Error

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

sorted_h = (sorted(h)[::-1])

for i in range(0,min(k,len(h))):
    h[i] = 0
hp = 0
for j in range(n,k):
    hp += h[j]
print(hp)

Submission status: Runtime Error

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

sorted_h = (sorted(h)[::-1])

for i in range(0,k):
    h[i] = 0
hp = 0
for j in range(n,k):
    hp += h[j]
print(hp)

Submission status: Runtime Error

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

h = input().split()
h.sort(reverse=True)

print(sum(h[k:]))

Submission status: Runtime Error

Solution code:
N, K=map(int, input().split())
List=sorted(list(map(int,input().split())))
a = 0
for i in range(N - k):
  a = a + List[i]
print(a)

Submission status: Runtime Error

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

sorted(h)

for i in range(k):
  h.pop()
  
print(sum(h))

Submission status: Runtime Error

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

ans = sum(h)

for i in range(k):
  ans -= max(h)
  h.pop(h.index(max(h)))

print(ans)

Submission status: Runtime Error

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

H_list.sort(reverse = True)

for i in range(K):
  del H_list[i]

print(sum(H_list))

Submission status: Runtime Error

Solution code:
n,k=(int(i) for i in input().split())
h=[0 for i in range(k)]
p=0
for i in input().split():
  p+=int(i)
  try:
      if h[0]<i:
        h[0]=int(i)
        h.sort()
  except IndexError:
    continue
print(p-sum(h))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n,k=(int(i) for i in input().split())
h=[]
for i in input().split():
  h.append(int(i))
h.sort()
if k!=0:
	for i in range(k):
 	  h.pop(-1)
print(sum(h))

Submission status: Runtime Error

Solution code:
n,k=(int(i) for i in input().split())
h=[]
for i in input().split():
  h.append(int(i))
h.sort()
for i in range(k):
  h.pop(-1)
print(sum(h)+k)

Submission status: Runtime Error

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

if N < K:
    times = N
else:
    times = K

for i in range(times):
    H.remove(max(H))

print(sum(H))

Submission status: Runtime Error

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

if N < K:
    times = N
else:
    times = K

for i in range(int(times)):
    H.remove(max(H))

print(sum(H))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
h,k = (int(x) for x in input().split())
list = list(map(int,input().split()))
for i in range(k):
	list.remove(max(list))
print(sum(list))

Submission status: Runtime Error

Solution code:
import math

h = int(input())
l = int(math.log(h, 2))

ans = math.pow(2, l+1) - 1
print(int(ans))

Submission status: Runtime Error

Solution code:
N, K = map(int,(input().split()))
H = list(map(int,(input().split())))
atk=0
for i in range(K):
  H.remove(max(H))

atk=SUM(H)
print(atk)

Submission status: Runtime Error

Solution code:
N, K = map(int,(input().split()))
H = list(map(int,(input().split())))
atk=0
for i in range(K):
  H.remove(max(H))

for j in range(len(H)):
  atk += H[j]
print(atk)

Submission status: Runtime Error

Solution code:
import sys
n,m = map(int,input().split(" "))
l = lsit(input().split(" "))
l = map(int, l)
if n <= m:
    print(0)
    sys.exit()
l.sort(reverse=True)
l.pop(l[:m])
print(sum(l))

Submission status: Runtime Error

Solution code:
import sys
n,m = map(int,input().split(" "))
l = lsit(input().split(" "))
l = map(int, l)
if n <= m:
    print(0)
    sys.exit()
for i in range(m):
    ma = max(l)
    ind = l.index(ma)
    l.pop(ind)
print(sum(l))

Submission status: Runtime Error

Solution code:
monster_num, special_num = input().split()
monster_list = [input() for _ in range(monster_num)]


monster_list = sorted(monster_list)

for _ in range(special_num):
  monster_list = monster_list[:-1]
  
print(sum(monster_list))

Submission status: Runtime Error

Solution code:
n, k = map(int, input().split())
h = input().split()
if (k >= len(h)):
    h.clear()
else:
    for i in range(k):
        m = max(h)
        h.remove(m)
b = sum(h)
print(b)

Submission status: Runtime Error

Solution code:
n, k = map(int, input(),split())
h = input().split()
for i in range(k):
    m = max(h)
    h.remove(m)
b = 0
for i in range(len(h)):
    b += h[i]

print(b)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N = input()
K = input()

A = []
for i in N:
  a = input()
  A.append(a)
  
A.sort()
A.reverse()
del A[K:]

for a in A:
  sum += a
  
print(sum)

Submission status: Runtime Error

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

for i in range(K):
	H.remove(max(H))
    
print(sum(H))

Submission status: Runtime Error

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

H.sort(reverse=True)

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

Submission status: Runtime Error

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

H.sorted(reverse=True)

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

Submission status: Runtime Error

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

H.sorted(reverse=True)

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

Submission status: Runtime Error

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

H.sorted(reverse=True)
ans=0

if K >= N:
    print(ans)
else:
    for i in range(K):
        ans += 1

Submission status: Runtime Error

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

H.sort(reverse=True)

if K >= N:
    print(0)
else:
    for i in range(K):
        del H[i]
    print(sum(H))

Submission status: Runtime Error

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

H.sort(reverse=True)

if K >= N:
    print(0)
else:
    for i in range(K):
        del H[i]
    print(sum(H))

Submission status: Runtime Error

Solution code:
import heapq

def heapsort(iterable):
    h = []
    for value in iterable:
        heapq.heappush(h, value)
    return [heapq.heappop(h) for i in range(len(h))]

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

heapsort(H)
# heapq.heapify(H)
# H.sort(reverse=True)

if K >= N:
    print(0)
else:
    for i in range(K):
        del H[i]
    print(sum(H))

Submission status: Runtime Error

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

H.sort(reverse=True)

if K >= N:
    print(0)
else:
    for i in range(K):
        del H[i]
    print(sum(H))

Submission status: Runtime Error

Solution code:
import math

EnemyCount, slayeCount = map(int, input().split())
enemyHealths = list(map(int, input().split(" "))).sort()

if EnemyCount < slayeCount:
    slayeCount = EnemyCount

for _ in range(slayeCount):
    del enemyHealths[-1]

print(sum(enemyHealths))

Submission status: Runtime Error

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

for i in range(0, k):
  cache = max(hlis)
  hlis.remove(cache)
print(sum(hlis))

Submission status: Runtime Error

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

for i in range(0, k):
  cache = max(hlis)
  hlis.remove(cache)
print(sum(hlis))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
a,b = map(int,input().split())
c = list(map(int,input().split()))
c.sort(reverse=True)
for i in range(0,b):
    c[i] = 0
print(sum(c))

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N, K = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
S = 0
for i in range(0, K):
  if not A.empty():
    A.pop_back()
print(sum(A))

Submission status: Runtime Error

Solution code:
n,k = input().split()
m = [int(x) for x in input().split()]
m.sort()
for i in range(k):
  if len(m) == 0:
    break
  m.pop(len(m))
print(sum(m))

Submission status: Runtime Error

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

sorted_H = sorted(H)
num = np.maximum(0, N-K)
answer = sum(sorted_H[:num])
print(answer)

Submission status: Runtime Error

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

if N <= K:
    print(0)
else:
    for num in range(K):
        Hi.pop((num+1)*-1)
    print(sum(Hi))

Submission status: Runtime Error

Solution code:
N,K = map(int,input().split())
H = list(map(int,input().split()))
h = H.sort()
i = 0
count = 0
while sum(h[N-K]) == 0:
  while h[N-K] == 0:
    count += 1
    while i <= N-K:
      i += 1
print(count)

Submission status: Runtime Error

Solution code:
N,K = map(int,input().split())
H = list(map(int,input().split()))
i = 0
count = 0
while sum(H[N-K]) == 0:
  while H[N-K] == 0:
    count += 1
    while i <= N-K:
      i += 1
print(count)

Submission status: Runtime Error

Solution code:
h = int(input())
ans = 0
c = 0
while h >0:
    ans += 2**c
    h //= 2
    c+= 1
print(ans)

Submission status: Runtime Error

Solution code:
h = int
(input())
ans = 0
c = 0
while h >0:
    ans += 2**c
    h //= 2
    c+= 1
print(ans)

Submission status: Runtime Error

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

A.sort()

ans = 0

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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: Runtime Error

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

if len(Hi) <= K:
    print(0)
else:
    for num in range(K):
        Hi.pop((num+1)*-1)
    print(sum(Hi))

Submission status: Runtime Error

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

h.sort()
tmp = 0
for i in range(n-k, n):
    tmp += h[i]
if k >= n:
    ans = 0
else:
    h.sort()
    tmp = 0
    for i in range(n-k, n):
        tmp += h[i]
    ans = (sum(h) - tmp)
print(ans)

Submission status: Runtime Error

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

h.sort()
tmp = 0
for i in range(n-k, n):
    tmp += h[i]
if k >= n:
    ans = 0
else:
    ans = (sum(h) - tmp)
print(ans)

Submission status: Runtime Error

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

tmp = 0
for i in range(n-k, n):
    tmp += h[i]
if k >= n:
    ans = 0
else:
    ans = (sum(h) - tmp)
print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

H.sort()

for i in range(0,K):
    H.pop()

print(sum(H))

Submission status: Runtime Error

Solution code:
from sys import stdin
N, K = [int(_) for _ in stdin.readline().rstrip().split()]
H = sorted([int(_) for _ in stdin.readline().rstrip().split()], reverse=True)
if K >= N:
    print(0)
else:
    for i in range(K):
        H.pop(i)
    print(sum(H))

Submission status: Runtime Error

Solution code:
N,K = map(int,input().split())
H = list(map(int,input().split()))
H.sort()
ans = K
for i in range(K):
    H.pop()
ans += sum(H)
print(ans)

Submission status: Runtime Error

Solution code:
N,K = map(int,input().split())
H = list(map(int,input().split()))
H.sort()
ans = K
for i in range(K):
    H.pop()
ans += sum(H)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import heapq
n, k = map(int, input().split())
hitpoint = [int(input()) for i in range(n)]

if k == 0:
  	print(sum(hitpoint))
else:
	bigs = heapq.nlargest(k, hitpoint)
    print(sum([i for i in hitpoint if i < bigs[-1]]))

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
l1 = list(map(int, input().split()))
l2 = list(map(int, input().split()))

N = l1[0]
K = l1[1]
l2.sort(reverse=True)
for i in range(K):
  l2[i] = 0
print(sum(l2))

Submission status: Runtime Error

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

Submission status: Runtime Error

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

h.sort(reverse = True)
for i in range(k-1):
    h[i] = 0
print(sum(h))

Submission status: Runtime Error

Solution code:
#include <iostream> 
#include <vector>
#include <string>
#include <numeric>
#include <algorithm>
using namespace std;
const int INF = 1e9 + 5;
int main() {

  int H, N, K;

  cin >> N >> K ;
  vector<int> dp(N, INF);
   unsigned  int attacks = 0;
  for(int i = 0; i < N; i++) {
    cin >> dp[i];
  }
  int k = 0;
  if(N > K) {
  sort(dp.begin(), dp.end());
  for(int i = 0; i < N-K; i++) {
    attacks += dp[i];
  }
  }

  cout << attacks << "\n";
  return 0;

     }

Submission status: Runtime Error

Solution code:
#include <iostream> 
#include <vector>
#include <string>
#include <numeric>
#include <algorithm>
using namespace std;
const int INF = 1e9 + 5;
int main() {

  int H, N, K;

  cin >> N >> K ;
  vector<int> dp(N, INF);
  unordered_set<int> u_set;
   unsigned  int attacks = 0;
  for(int i = 0; i < N; i++) {
    cin >> dp[i];
  }
  int min_num = dp[0];
  bool done = false;
  int k = 0;
  if(N > K) {
  sort(dp.begin(), dp.end());
  for(int i = 0; i < N-K; i++) {
    attacks += dp[i];
  }
  }

  cout << attacks << "\n";
  return 0;

     }

Submission status: Runtime Error

Solution code:
s = [list(map(int,input().split())) for i in range(2)]
t = s[0]
N = t[0]
K = t[1]
H = s[1]
for i in range(K):
    a = max(H)
    H.remove(a)
print(sum(H))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N,K= map(int,input().split())
list_nums = []
for i in range(0, N):
    cur_num = int(input())
    list_nums.append(cur_num)

list_nums.sort();
done = False;
k = 0;
while(done is not True and  K != 0):
    if(k == N):
        done = True;
        break;
    index = N - k - 1;
    list_nums.pop(index);
    K = K - 1;
    k = k + 1;

attacks = 0;
attacks = sum(list_nums)

print(attacks)

Submission status: Runtime Error

Solution code:
h = int(input())
mem = [0] * 100
cnt = 0
 
def atk(k):
    if k == 1:
        mem[1] = 1
        return 1
    else:
        j = int(k // 2)
        l = 0
        while k / ( 2 ** l) >1:
            l += 1
 
        if mem[l] == 0:
            mem[l] = atk(j) * 2 + 1
            return mem[l]
        else:        
            return mem[l]

atk(h)
mem.sort(reverse = True)
print(mem[0])

Submission status: Runtime Error

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

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

Submission status: Runtime Error

Solution code:
N, K = map(int,input().split())
H = list(input().split())
 
if K >= N:
    print(0)
elif N > K:
    if K == 0:
        print(sum(int(i) for i in H))
    else:
      	# ここを追加
      	for i in range(k):
        	H.remove(max(H))
        print(sum(int(i) for i in H))

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
class Main:
    s = list(map(int, input().split()))
    n = s[0]
    k = s[1]
    sum = 0
    ksum=0
    list = [int(i) for i in input().split()]
    list = sorted(1, reverse=True)
    list[:k]
    for num in list:
        sum += num
    for knum in list[:k]:
        ksum += knum
    print(sum-ksum)

Submission status: Runtime Error

Solution code:
import math

n, k = [int(x) for x in input().split()]

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

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

s_n = sorted(h_n)

log_sum = math.log(sum(s_n[:n - k]))

print(round(math.exp(log_sum)))

Submission status: Runtime Error

Solution code:
import math
m, n = map(int, input().split())
li = input().split()
res=[]
for i in li:
    res.append(int(i))

res.sort(reverse=True)

while n != 0:
    res.pop(0)
    n -= 1

print(sum(res))

Submission status: Runtime Error

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

if(len(this_list) < int(K)):
    print(0)
else:
    final_list =[]
    max1 = 0
    for i in range(int(K)):
  
        for j in range(len(this_list)):
            if(this_list[j])>max1:
                max1 = this_list[j]
        this_list.remove(max1)
        final_list.append(max1)

    print(sum(this_list))

Submission status: Runtime Error

Solution code:
N, K = input().split()
this_list = [int(x) for x in input().split()]
final_list =[]
max1 = 0
if(len(this_list) < int(K)):
    print(0)
else:
    for i in range(int(K)):
  
        for j in range(len(this_list)):
            if(this_list[j])>max1:
                max1 = this_list[j]
        this_list.remove(max1)
        final_list.append(max1)

    print(sum(this_list))

Submission status: Runtime Error

Solution code:
import math

n, k = [int(x) for x in input().split()]

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

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

s_n = sorted(h_n)

log_sum = math.log(sum(s_n[:n - k]))

print(math.exp(log_sum))

Submission status: Runtime Error

Solution code:
import sys
input = sys.stdin.readline
input_line = list(map(int,input().split()))
input_hp = list(map(int,input().split()))

input_hp.sort(reverse=True)
try:
    [input_hp.pop(_) for _ in range(input_line[1])]
    print(sum(input_hp))
except IndexError:
    print(‘0’)

Submission status: Runtime Error

Solution code:
import math

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:
    print(0)
else:
    [H.pop(i) for i in range(K)]
    print(sum(H))