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: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

h = sorted(h, reverse=True)

try:
    for i in range(k):
        h.pop(0)
except IndexError:
    pass

print(sum(h) if h != 0 else 0)

Submission status: Time Limit Exceeded

Solution code:
n, k = map(int, input().split())
s = list(map(int, input().split()))
# s.sort()
if k > len(s):
    k = len(s)
for j in range(1, k+1):
    s[s.index(max(s))] = 0
print(sum(s))

Submission status: Time Limit Exceeded

Solution code:
n, k = map(int, input().split())
s = list(map(int, input().split()))
s.sort()
if k > len(s):
    k = len(s)
for i in s:
    for j in range(1, k+1):
        s[-j] = 0
print(sum(s))

Submission status: Time Limit Exceeded

Solution code:
N, K = map(int, input('').split(' '))
H = input('').split(' ')
if(K >= N):
    print(0)
    exit(0)
H = [int(i) for i in H]
for j in range(K):
    H[H.index(max(H))] = 0
print(sum(H))

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python3
import sys
N, K = map(int, input().split())
H = sorted(list(map(int, input().split())), reverse=True)
l = len(H)
if K != 0:
    if len(H) <= K:
        print(0)
        sys.exit()
    for i in range(K):
        H.pop(0)
    if len(H)==0:
        print(0)
    else:
        print(sum(H))
else:
    print(sum(H))

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python3
import sys
N, K = map(int, input().split())
H = sorted(list(map(int, input().split())), reverse=True)
l = len(H)
if K != 0:
    for i in range(K):
        if len(H)==0:
            print(0)
            sys.exit()
        else:
            H.pop(0)
    if len(H)==0:
        print(0)
    else:
        print(sum(H))
else:
    print(sum(H))

Submission status: Time Limit Exceeded

Solution code:
list = input().split(" ")
N = int(list[0])
K = int(list[1])
list_hp = input().split(" ")
list_hp = [int(i) for i in list_hp]
list_hp = sorted(list_hp,reverse=True)

if K < N:
    for i in range(K):
        list_hp.pop(0)
    print(sum(list_hp))
    
else:
    print(0)

Submission status: Time Limit Exceeded

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

b.sort(reverse=True)
x=a[1]
y=a[0]
if x>=y:
	print(0)
else:
	for i in range(x):
		del b[0]
	print(sum(b))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8
# Your code here!
def fennec(n, k):
    if n <= k:
        print("0")
    else:
        hp_list = list(map(int, input().split()))
        i = 1
        while i <= int(k): 
            del hp_list[hp_list.index(max(hp_list))]
            i += 1
        attack = sum(hp_list)
        print(attack)
        
        
n, k = map(int, input().split())
fennec(n, k)

Submission status: Time Limit Exceeded

Solution code:
n,k=map(int,input().split())
H=list(map(int,input().split()))
H.sort()
H.reverse()
for i in range(k):
    if len(H)>0:
        H.pop(0)
print(sum(H))

Submission status: Time Limit Exceeded

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

    for _ in range(K):
        if(len(H) > 0):
            maximum = max(H)
            H.remove(maximum)

    print(sum(H))

if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
n, k = map(int, input().split())
h = list(map(int, input().split()))
D = 1
if k != 0:
  while D <= k:
    if h == []:
      print(0)
      exit()
    else:
      h.remove(max(h))
    D += 1
print(sum(h))

Submission status: Time Limit Exceeded

Solution code:
n, k = map(int, input().split())
h = list(map(int, input().split()))
D = 1
if k != 0:
  while D <= k:
    if h == []:
      print(0)
      exit()
    else:
      h.remove(max(h))
      D += 1
sum1 = sum(h)
print(sum1)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

if n > k:
    for i in range(k):
        h.remove(max(h))
    print(sum(h))
else:
    print(0)

Submission status: Time Limit Exceeded

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

if n > k:
    for i in range(k):
        h.pop(0)
    print(sum(h))
else:
    print(0)

Submission status: Time Limit Exceeded

Solution code:
N,K=map(int,input().split())
ans=0
if N<=K:
  pass
else:
  A=list(map(int,input().split()))
  for i in range(N-K):
    ans+=min(A)
    A.remove(min(A))  
print(ans)

Submission status: Time Limit Exceeded

Solution code:
N,K=map(int,input().split())
ans=0
if N<K:
  pass
else:
  A=list(map(int,input().split()))
  for i in range(N-K):
    ans+=min(A)
    A.remove(min(A))  
print(ans)

Submission status: Time Limit Exceeded

Solution code:
N,K=map(int,input().split())
A=list(map(int,input().split()))
ans=0
if N<K:
  pass
else:
  for i in range(N-K):
    ans+=min(A)
    A.remove(min(A))  
print(ans)

Submission status: Time Limit Exceeded

Solution code:
N,K=map(int,input().split())
A=list(map(int,input().split()))
if N<K:
  ans=0
else:
  for i in range(K):
    A.remove(max(A))
  ans=sum(A)
print(ans)

Submission status: Time Limit Exceeded

Solution code:
N, K = (int(x) for x in input().split(' '))
H    = [int(x) for x in input().split(' ')]
#ソート処理
list.sort(H, reverse=True)
#K回最大値をHから消す
while N > 0 and K > 0:
  del H[0]
  N -= 1
  K -= 1
#総和を出力
print(sum(H))

Submission status: Time Limit Exceeded

Solution code:
import math

class Culuculation():
  H = 0
  K = 0
  H = []
  
  def __init__(self):
    self.N, self.K = (int(x) for x in input().split(' '))
    self.H = [int(x) for x in input().split(' ')]
    
  def culuculation(self):
    #Hを降順にソートしてK回POPし、母数を減らす
    list.sort(self.H, reverse=True)
    for i in range(self.K):
      self.H.pop(0)
      if len(self.H) == 0:
        break
    #残ったリストHを合算して出力
    print(sum(self.H))
    
def main():
  tmp = Culuculation()
  tmp.culuculation()

if __name__=='__main__':
  main()

Submission status: Time Limit Exceeded

Solution code:
# N体の敵、K回の必殺技
N, K = map(int, input().strip().split(' '))
N_list = list(map(int, input().strip().split(' ')))
sorted_N = sorted(N_list, reverse=True)

# 必殺技で体力が多い敵からヤる
for i in range(K):
  sorted_N.pop(0)
  if sorted_N == []:
    break

if sorted_N ==[]:
  print(0)
else:
  print(sum(sorted_N))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
NK = list(map(int, input().split()))
Hi = list(map(int, input().split()))

N = NK[0]
K = NK[1]
Hi.sort()
reversed_Hi = list(reversed(Hi))

for i in range(K):
    if not reversed_Hi:
        break

    if K == 0:
        break
    else:
        K -= 1
        reversed_Hi.pop(0)

count = 0
for i in reversed_Hi:
    count += i

print(count)

Submission status: Time Limit Exceeded

Solution code:
kazu1 = list(map(int, input().split()))
kazu2 = list(map(int, input().split()))
n = 0

for i in range(kazu1[1]):
    kazu2[kazu2.index(max(kazu2))] = 0

n += sum(kazu2)

print(n)

Submission status: Time Limit Exceeded

Solution code:
import math

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

h.sort(reverse=True)

if n <= k:
    print(0)
else:
    for _ in range(k):
        h.pop(0)
    ans = sum(h)
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
import math

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

h2 = sorted(h, reverse=True)

if n <= k:
    print(0)
else:
    for _ in range(k):
        h2.pop(0)
    ans = sum(h2)
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
import sys
read = sys.stdin.buffer.read#全部読み込むやつ
readline = sys.stdin.buffer.readline#1行読み込むやつ
readlines = sys.stdin.buffer.readlines#リストで読み込むらしい

N,K,*H = map(int,read().split())
N -= K
if N <= 0:
    print(0)
    exit()
    
for i in range(K):
    H.remove(max(H))
    
print(sum(H))

Submission status: Time Limit Exceeded

Solution code:
n, k = map(int, input().split())
H = list(map(int, input().split()))
if k >= n: print(0)
else:
    for i in range(k):
        H.remove(max(H))
    print(sum(H))

Submission status: Time Limit Exceeded

Solution code:
inp = input().split()
n,k = map(int, inp)
nums = list(input().split())
nums_list = list(map(int, nums))
if len(nums_list) < k:
    print(0)
else:
    for i in range(k):
        nums_list.pop(nums_list.index(max(nums_list)))
    print(sum(nums_list))

Submission status: Time Limit Exceeded

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

a.sort()

if h >= n and n !=0 :
  for i in range(n):
    a.pop()
    ans = sum(a)
elif n ==0:
  ans = sum(a)
else:
  ans = 0
  
print(ans)

Submission status: Time Limit Exceeded

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))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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]
for i in range(min(K, H.shape[0])):
    H = np.delete(H, 0)

print(np.sum(H))

Submission status: Time Limit Exceeded

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

if N <= K:
    print("0")
    
else:
    for i in range(K):
        hp.remove(max(hp))
    print(sum(hp))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

h.sort()
for i in range(k):
    if sum(h) == 0:
        break
    else:
        h.pop(-1)

print(sum(h))

Submission status: Time Limit Exceeded

Solution code:
n,k = map(int,input().split())
h = sorted(list(map(int,input().split())), reverse=True)
if k >= n:
  print(0)
else:
  for i in range(k):
    h.pop(0)
  print(sum(h))

Submission status: Time Limit Exceeded

Solution code:
n,k = map(int,input().split())
h = sorted(list(map(int,input().split())), reverse=True)
for i in range(k):
  try:
    h.pop(0)
  except IndexError:
    break
print(sum(h))

Submission status: Time Limit Exceeded

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

if enemy_num >= dethblow_num:
    for i in range(dethblow_num):
        enemy_hp.remove(max(enemy_hp))
else:
    enemy_hp.clear()
    enemy_hp = [0]
    
print(sum(enemy_hp))

Submission status: Time Limit Exceeded

Solution code:
def attack(h, k, arr):
    for _ in range(k):
        if len(arr) == 0:
            return 0
        arr.remove(max(arr))
    return sum(arr)

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N, K = map(int, input().split())
H = list(map(int, input().split()))
list.sort(H, reverse=True)
for i in range(K):
    if len(H) != 0:
        H.pop(0)
    else:
        print("0")
        exit()
print(sum(H))

Submission status: Time Limit Exceeded

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

#ListH.sort(reverse=True)
sum=0

if N > K:
    for i in range(K):
        ListH.remove(max(ListH))
        
    for i in range(N-K):
        sum+=ListH[i]
else:
    sum=0
    
print(sum)

Submission status: Time Limit Exceeded

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

list_H.sort()

while K :
    if list_H :
        list_H.pop()
    K -= 1

sum = 0
while list_H :
    sum += list_H[0]
    list_H.pop(0)

print(sum)

Submission status: Time Limit Exceeded

Solution code:
n,k = map(int,input().split())
mlist = list(map(int,input().split()))
m = sh = 0
kaisuu = at = 0
sh = sum(mlist)
kk =k+1
 
if n < k:
    print(0)
else:
    for m in range(1,kk):
        at=max(mlist)
        mlist.remove(at)
        k -= 1
        sh = sh -at
        if sh <= 0:
            break
    kaisuu = kaisuu + sh
 
    print(kaisuu)

Submission status: Time Limit Exceeded

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

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

    print(kaisuu)

Submission status: Time Limit Exceeded

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

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

    print(kaisuu)

Submission status: Time Limit Exceeded

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

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

print(kaisuu)

Submission status: Time Limit Exceeded

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

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

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

Submission status: Time Limit Exceeded

Solution code:
n, k = map(int, input().split())
ls = list(map(int, input().split()))
m = [0 for l in range(0, k)]
for i in range(0,len(ls)):
    for j in range(0,len(m)):
        if m[j]<ls[i]:
            c = m[j:]
            m[j] = ls[i]
            m[j+1:] = c[:-1]
            break
print(sum(ls)-sum(m))

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8
# Your code here!
import numpy as np

HA=input().split()
N=int(HA[0])
K=int(HA[1])

sum=0

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

T.sort(reverse=True)


if N>K:
    for i in range(K):
        T.pop(0)
    
    
    tt=np.array(T)


    print(np.sum(tt))
else:
    print(0)

Submission status: Time Limit Exceeded

Solution code:
N,K = map(int,input().split())
H = list(map(int,input().split()))
for i in range(K):
  max_value = max(H)
  max_index = H.index(max_value)
  H[max_index] = 0
count = sum(H)
print(count)

Submission status: Time Limit Exceeded

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

if n <= k:
    print(0)

    exit()

H = sorted(h)

for i in range(k):
    H.remove(H[-1])

print(sum(H))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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: Time Limit Exceeded

Solution code:
n, k = map(int, input().split())
h = list(map(int, input().split()))
count = 0
 
while len(h) > 0:
  if k > 0:
    k -= 1
    h.remove(max(h))
  else:
    break
 
for i in h:
  count += i
  
print(count)

Submission status: Time Limit Exceeded

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

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

cnt = 0
atk = 0
while True:
    for i in range(N):
        if H[i] <= 0:
            continue
        else:
            if K > 0:
                K -= 1
                H[i] = 0
                cnt += 1
            else:
                H[i] -= 1
                atk += 1
                if H[i] == 0:
                    cnt += 1

    if cnt == N:
        break

print(atk)

Submission status: Time Limit Exceeded

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

b.sort(reverse=True)
c = b[a[1]:]
cnt = 0
h = 0
for i in range(len(c)):
  h = c[i]
  while True:
    h -= 1
    cnt += 1
    if h <= 0:
      break
print(cnt)

Submission status: Time Limit Exceeded

Solution code:
data  = [int(_) for _ in input().split()]
enemy = [int(_) for _ in input().split()]
#print(type(enemy))
#print(enemy)

if len(enemy) < data[1]:
    print(0)
    exit()

for _ in range(data[1]):
#    print(enemy)
    enemy.remove(max(enemy))
#print(enemy)

print(sum(enemy))

Submission status: Time Limit Exceeded

Solution code:
a,b=input().split()
a=int(a);b=int(b)
l=list(map(int,input().split()))
if len(l) <= b:
  print(0)
else:
  for i in range(1,b+1):
    l.remove(max(l))
  print(sum(l))

Submission status: Time Limit Exceeded

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

h.sort()
s = []
if k == 0:
    s = h
else:
    for i in range(k):
        s = h[:-k]

print(sum(s))

Submission status: Time Limit Exceeded

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

h.sort()
h.reverse()
for i in range(k):
    h.pop(0)
    if len(h) == 0:
        break
print(sum(h))

Submission status: Time Limit Exceeded

Solution code:
N, K = [int(_) for _ in input().split()]
H = [int(_) for _ in input().split()]
list_H = sorted(H, reverse=True)
if len(H) < K:
    print(0)
else:
    for k in range(K):
        if len(list_H) > 0:
            list_H.pop(0)
    print(sum(list_H))

Submission status: Time Limit Exceeded

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):
    if len(list_H) > 0:
        list_H.pop(0)
print(sum(list_H))

Submission status: Time Limit Exceeded

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):
    if len(list_H) > 0:
        list_H.pop(0)
attack = 0
for i in list_H:
    attack += i
print(attack)

Submission status: Time Limit Exceeded

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

for k in range(K):
    max_H = 0
    for i in H:
        if max_H < i:
            max_H = i
    if len(H) > 0:
        H.remove(max_H)

attack = 0
for i in H:
    attack += i

print(attack)

Submission status: Time Limit Exceeded

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

ans = []
for i in A:
    if K > 0:
        A.remove(max(A))
        ans.append(i//K)
    else:
        ans.append(i)
print(sum(ans))

Submission status: Time Limit Exceeded

Solution code:
N, K = map(int, input().split())
H = [int(h) for h in input().split()]
if len(H) > K:
    for i in range(K):
        H.remove(max(H))
    print(sum(H))
else: 
    print(0)

Submission status: Time Limit Exceeded

Solution code:
N, K = map(int, input().split())
H = [int(h) for h in input().split()]
for i in range(K):
    if len(H) > 0:
        H.remove(max(H))
print(sum(H))

Submission status: Time Limit Exceeded

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

for i in range(k):
    if len(h) == 0:
        print(0)
        exit()
    m = max(h)
    h.remove(m)

print(sum(h))

Submission status: Time Limit Exceeded

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


lst = input().split(" ")
hps = []
for l in lst:
  hps.append(int(l))

hps.sort(reverse=True)

for k in range(K):
  if hps:
  	hps.pop(0)
  else:
    break

if hps:
  sum_hps = sum(hps)
else:
  sum_hps = 0
print(sum_hps)

Submission status: Time Limit Exceeded

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

if N < K:
    times = int(N)
else:
    times = int(K)

H_i =[int(i) for i in H]

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

print(sum(H_i))

Submission status: Time Limit Exceeded

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

for _ in range(k):
  max_num = max(data)
  max_index = data.index(max_num)
  data[max_index] = 0

print(sum(data))

Submission status: Time Limit Exceeded

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]<int(i):
        h[0]=int(i)
        h.sort()
  except IndexError:
    continue
print(p-sum(h))

Submission status: Time Limit Exceeded

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

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

for i in range(int(times)):

    H.pop(H.index(max(H)))

H = [int(i) for i in H]

print(sum(H))

Submission status: Time Limit Exceeded

Solution code:
N, K = map(int,input().split())
H = list(map(int, input().split()))
H0=[]
m=0
s=0

if N<K:
    print(0)
else:
    for i in range(K):
        for j in range(len(H)-1):
            if H[j]<H[j+1]:
                m=j+1
        H0.append(H.pop(m))
        m=0
    print(sum(H))

Submission status: Time Limit Exceeded

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

for i in range(int(K)):
    if len(H) == 0:
        break

    H.pop(H.index(max(H)))

H = [int(i) for i in H]

print(sum(H))

Submission status: Time Limit Exceeded

Solution code:
# C - Fennec vs Monster

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

for i in range(min({k, n})):
    h.remove(max(h))

a = sum(h)
print(a)

Submission status: Time Limit Exceeded

Solution code:
n,k = (int(x) for x in input().split())
list = list(map(int,input().split()))
if n>k:
	for i in range(k):
		list.remove(max(list))
	print(sum(list))
else:
	print(0)

Submission status: Time Limit Exceeded

Solution code:
import sys
n,m = map(int,input().split(" "))
l = list(map(int,input().split(" ")))
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: Time Limit Exceeded

Solution code:
monster_num, special_num = map(int ,input().split())
monster_list = list(map(int, input().split()))

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

Submission status: Time Limit Exceeded

Solution code:
input1 = input().split(' ')
input2 = input().split(' ')
n = int(input1[0])
k = int(input1[1])
h = input2

for _ in range(k):
  if len(h) == 0:
    break
  h.pop(h.index(max(h)))

h = list(map(int, input2))
print(sum(h))

Submission status: Time Limit Exceeded

Solution code:
input1 = input().split(' ')
input2 = input().split(' ')
n = int(input1[0])
k = int(input1[1])
h = list(map(int, input2))

for _ in range(k):
  if len(h) == 0:
    break
  h.pop(h.index(max(h)))
print(sum(h))

Submission status: Time Limit Exceeded

Solution code:
n,k=map(int,input().split())
l=list(map(int,input().split()))
a=0
for i in range(max(0,n-k)):
    a+=min(l)
    l.remove(min(l))
print(a)

Submission status: Time Limit Exceeded

Solution code:
n,k=map(int,input().split())
l=list(map(int,input().split()))
if n>k:
    for i in range(k):
        l.remove(max(l))
    print(sum(l))
else:
    print(0)

Submission status: Time Limit Exceeded

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 = 0
for i in range(len(h)):
    b += int(h[i])

print(b)

Submission status: Time Limit Exceeded

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

print(b)

Submission status: Time Limit Exceeded

Solution code:
n, k = map(int, input().split()) ###n:モンスターの数，k:必殺技の回数
h=list(map(int,input().split())) ###h:モンスターの体力
if k>0:
    for i in range(k):
        if n<=k:
            h.clear()
        else:
            a=max(h)
            h.remove(a)
print(sum(h))

Submission status: Time Limit Exceeded

Solution code:
def add_num(List):
  res=0
  for y in List:
    res += y
  print(res)

N, K=map(int,input().split())
List=list(map(int,input().split()))
if N <= K:
  print(0)
elif K is not 0:
  for x in range(0, K):
    x=List.index(max(List))
    List.pop(x)
  add_num(List)
else:
  add_num(List)

Submission status: Time Limit Exceeded

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

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

print(sum(H))

Submission status: Time Limit Exceeded

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

for i in range(K):
    num = H.index(max(H))
    H[num] = 0

print(sum(H))

Submission status: Time Limit Exceeded

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

if N <= K:
  print(ans)
else:
  H.sort(reverse=True)
  for i in range(K):
    H.pop(0)
  ans = sum(H)
  print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
eneNum, spNum = map(int, input().split())
eneHp = map(int, input().split())
eneHpList = list(eneHp)

count = 0
for i in range(spNum):
    if len(eneHpList) > 0:
        maxEneHp = max(eneHpList)
        eneHpList.remove(maxEneHp)
count = sum(eneHpList)

print("{}".format(count))

Submission status: Time Limit Exceeded

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

for i in range(K):
    if len(H)!=0:
        H.remove(max(H))
        #print(H)
    else:
        #print(0)
        break
print(sum(H))

Submission status: Time Limit Exceeded

Solution code:
n, k = map(int, input().split())
h = sorted(map(int, input().split()), reverse=True)
if k == 0:
    print(sum(h))
elif k < n:
    for i in range(k):
        h.pop(0)
    print(sum(h))
else:
    print(0)

Submission status: Time Limit Exceeded

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

while K > 0 and len(H) > 0:
    H.pop(0)
    K -= 1

c = 0
for h in H:
    c += h

print(c)

Submission status: Time Limit Exceeded

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

if k >= len(h):
    print(0)
    
else:
    h.sort(reverse=True)
    for _ in range(k):
        del h[0]    

    num = 0
    for i in h:
        num+=i
    print(num)

Submission status: Time Limit Exceeded

Solution code:
N,K=map(int,input().split())
if K>=N:
	print(0)
	quit()
L = [int(x) for x in input().split()]
L.sort()
if K:
	for _ in range(K):
		L.remove(L[-1])
print(sum(L))

Submission status: Time Limit Exceeded

Solution code:
# coding utf-8
import math
N, K = map(int, input().rstrip().split())

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

if N > K:
    for i in range(K):
        H.remove(max(H))
    ans = sum(H)
else:
    ans = 0

print(ans)

Submission status: Time Limit Exceeded

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

while(K>0):
    maxHeath = max(H)
    ind = H.index(maxHeath)
    H[ind]=0
    K-=1

allAttack = 0
for i in range(0,N):
    allAttack+=H[i]
print(allAttack)

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python3
from itertools import product, permutations, combinations
from bisect import bisect_right,bisect_left
INF = float('inf')

N, K=map(int, input().split())
HP=sorted(list(map(int, input().split())), reverse=True)

for i in range(K):
    if len(HP) > 0:
        HP.pop(0)

print(sum(HP))

Submission status: Time Limit Exceeded

Solution code:
n,k=map(int,input().split())
h=list(map(int,input().split()))
sort_h=sorted(h,reverse=True)
if(n<k):
    print('0')
elif(k==0):
    print(sum(h))
else:
    for i in range(k):
        sort_h.pop(0)
    print(sum(sort_h))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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]
if K > N:
    print(0)
elif K < N//2:
    for i in range(K):
        a = max(H)
        H.remove(a)
    print(sum(H))
else:
    m = 0
    for i in range(N - K):
        a = min(H)
        H.remove(a)
        m = m + a
    print(m)

Submission status: Time Limit Exceeded

Solution code:
N, K = map(int, input().split())
 
list_monster = list(map(int, input().split()))
list_monster.sort(reverse = True) 
 
if N <= K:
  print(0)
  
elif K == 0:
  print(sum(list_monster))
  
else:
  for i in range(K):
    
    list_monster.pop(0)
 
  print(sum(list_monster))