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:
H,K=map(int,input().split())
H=list(map(int,input().split()))
d=sum(H)
c=[]
for i in range(K):
  c.append(max(H))
  H.remove(max(H))
  if H.count(max(H))>=2:
    H.append(max(H))
if d-sum(c)>0:
  print(d-sum(c))
else:
  print(0)

Submission status: Time Limit Exceeded

Solution code:
n, k = map(int, input().split())
l = list(map(int, input().split()))
l = sorted(l)[::-1]
if k >= n:
    print(0)
else:
    for i in range(k):
        l.pop(0)
    s = sum(l)
    print(s)

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8

import sys
input=sys.stdin.readline

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

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

Submission status: Time Limit Exceeded

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

H = input().split()
H = [int(s) for s in H]
H.sort(reverse=True)

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

  sumdata = 0
  for i in range(0,len(H)):
    sumdata += H[i]
  print(sumdata)

Submission status: Time Limit Exceeded

Solution code:
h, k = map(int, input().split())
As = list(map(int, input().split()))
try:
    for i in range(k):
        As_max = max(As)
        #print(As_max)
        As.remove(As_max)
    As_sum = sum(As)
    #print(As)
    print(As_sum)

except ValueError:
    print(0)

Submission status: Time Limit Exceeded

Solution code:
def quicksort2(numbers):
    length = len(numbers)
    if length <= 1:
        return numbers
    pivot = numbers[0]
    leftside = []
    rightside = []
    for x in numbers[1:]:
        if x <= pivot:
            leftside.append(x)
        else:
            rightside.append(x)
    leftside = quicksort2(leftside)
    rightside = quicksort2(rightside)
    return leftside + [pivot] + rightside
N, K = map(int, input().split())
H_list = list(map(int, input().split()))
H_list = quicksort2(H_list)
if N-K <= 0:
    print(0)
else:
    print(sum(H_list[0:N-K]))

Submission status: Time Limit Exceeded

Solution code:
"""
Author    : co_devil Chirag Garg
Institute : JIIT
"""
from math import *
from sys import stdin, stdout
import itertools
import os
import sys
import threading
from collections import deque, Counter, OrderedDict, defaultdict
from heapq import *
# from math import ceil, floor, log, sqrt, factorial, pow, pi, gcd
# from bisect import bisect_left,bisect_right
# from decimal import *,threading
from fractions import Fraction
mod = int(pow(10, 9)+7)


def ii(): return int(input())


def si(): return str(input())


def mi(): return map(int, input().split())


def li(): return list(mi())


def fii(): return int(stdin.readline())


def fsi(): return str(stdin.readline())


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


def fli(): return list(fmi())


abd = {'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12,
       'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24,
       'z': 25}


def getKey(item): return item[0]


def sort2(l): return sorted(l, key=getKey)


def d2(n, m, num): return [[num for x in range(m)] for y in range(n)]


def isPowerOfTwo(x): return (x and (not (x & (x - 1))))


def decimalToBinary(n): return bin(n).replace("0b", "")


def ntl(n): return [int(i) for i in str(n)]


def powerMod(x, y, p):
    res = 1
    x %= p
    while y > 0:
        if y & 1:
            res = (res * x) % p
        y = y >> 1
        x = (x * x) % p
    return res


graph = defaultdict(list)
visited = [0] * 1000000
col = [-1] * 1000000


def bfs(d, v):
    q = []
    q.append(v)
    visited[v] = 1
    while len(q) != 0:
        x = q[0]
        q.pop(0)
        for i in d[x]:
            if visited[i] != 1:
                visited[i] = 1
                q.append(i)
        print(x)


def make_graph(e):
    d = {}
    for i in range(e):
        x, y = mi()
        if x not in d:
            d[x] = [y]
        else:
            d[x].append(y)
        if y not in d:
            d[y] = [x]
        else:
            d[y].append(x)
    return d


def gr2(n):
    d = defaultdict(list)
    for i in range(n):
        x, y = mi()
        d[x].append(y)
    return d


def connected_components(graph):
    seen = set()

    def dfs(v):
        vs = set([v])
        component = []
        while vs:
            v = vs.pop()
            seen.add(v)
            vs |= set(graph[v]) - seen
            component.append(v)
        return component

    ans = []
    for v in graph:
        if v not in seen:
            d = dfs(v)
            ans.append(d)
    return ans


def primeFactors(n):
    s = set()
    while n % 2 == 0:
        s.add(2)
        n = n // 2
    for i in range(3, int(sqrt(n)) + 1, 2):
        while n % i == 0:
            s.add(i)
            n = n // i
    if n > 2:
        s.add(n)
    return s


def find_all(a_str, sub):
    start = 0
    while True:
        start = a_str.find(sub, start)
        if start == -1:
            return
        yield start
        start += len(sub)


def SieveOfEratosthenes(n, isPrime):
    isPrime[0] = isPrime[1] = False
    for i in range(2, n):
        isPrime[i] = True
    p = 2
    while (p * p <= n):
        if (isPrime[p] == True):
            i = p * p
            while (i <= n):
                isPrime[i] = False
                i += p
        p += 1
    return isPrime


def dijkstra(edges, f, t):
    g = defaultdict(list)
    for l, r, c in edges:
        g[l].append((c, r))

    q, seen, mins = [(0, f, ())], set(), {f: 0}
    while q:
        (cost, v1, path) = heappop(q)
        if v1 not in seen:
            seen.add(v1)
            path = (v1, path)
            if v1 == t:
                return (cost, path)

            for c, v2 in g.get(v1, ()):
                if v2 in seen:
                    continue
                prev = mins.get(v2, None)
                next = cost + c
                if prev is None or next < prev:
                    mins[v2] = next
                    heappush(q, (next, v2, path))
    return float("inf")


def binsearch(a, l, r, x):
    while l <= r:
        mid = l + (r-1)//2
        print(mid)
        if a[mid]:
            return mid
        elif a[mid] > x:
            l = mid-1
        else:
            r = mid+1
    return -1


n, k = mi()
l = li()
l = sorted(l)[::-1]
if k >= n:
    print(0)
else:
    for i in range(k):
        l.pop(0)
    s = sum(l)
    print(s)

Submission status: Time Limit Exceeded

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

for i in range(k):
    if len(li) > 0:
        m = li.index(max(li))
        li.pop(m)

print(sum(li))

Submission status: Time Limit Exceeded

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

a.sort(reverse=True)
attack = 0
#print(min(c[1],c[0]))

for i in range(min(c[1],c[0])):
  a.pop(0)

#print(a)
for i in range(len(a)):
  attack += a[i]

print(attack)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
N, M = map(int, input().split())


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


count=0
if N>=M:
    for i in range(N-M):
        x1=np.argmin(A)
        x1=A.pop(x1)
        count+=x1
    print(count)



else:
    print(0)

Submission status: Time Limit Exceeded

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

li = list(map(int, input().split()))
li.sort(reverse=True)

for i in range(K):
  if len(li) == 0:
    break
  del li[0]
  
print(sum(li))

Submission status: Time Limit Exceeded

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

HP = sum(H)
count = 0
Z = 0
if K >= len(H):
    print(0)

else:
    for k in range(K):
        Z += sorted(H, reverse=True)[k]
    hp = HP - Z
    print(hp)

Submission status: Time Limit Exceeded

Solution code:
HK = list(map(int, input().split()))
M = list(map(int, input().split()))

k = HK[1]

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

M.sort(reverse=True)


while k > 0:
    if (len(M) == 0):
        break
    M.pop(0)
    k -= 1

damage = 0
for i in range(len(M)):
    damage += M[i]

print(damage)

Submission status: Time Limit Exceeded

Solution code:
N,M = map(int,input().split())
A =list(map(int,input().split()))
new_list = sorted(A, reverse=True)
ans = 0
for i in range(M):
    if not new_list:
        break
    else:
        del new_list[0]
        
if not new_list:
    print(ans)
else:
    ans +=sum(new_list)
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
a=[int(i) for i in input().split()]
b=[int(i) for i in input().split()]
if a[1]>=len(b):
    print(0)
else:
    c=[]
    for i in range(a[0]-a[1]):
        c.append(min(b))
        b.remove(min(b))
    print(sum(c))

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

cnt = 0

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

  cnt += sum(H)

  print(cnt)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

count = 0

if N<K:
    print(0)
else:
    for i in range(0,K):

        # 最大値を見つける
        H_max = max(H_list)
        # 最大値を１つリストから削除
        H_list.remove(H_max)

    # リスト内の残りの数を合計
    count = sum(H_list)
    print(count)

Submission status: Time Limit Exceeded

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

HP = sum(H)
count = 0
Z = 0
if K >= len(H):
    print(0)

else:
    for k in range(K):
        Z += sorted(H, reverse=True)[k]
    hp = HP - Z
    while(hp > 0):
        hp = hp - 1
        count += 1
    print(count)

Submission status: Time Limit Exceeded

Solution code:
NK=input().split()
N=int(NK[0])
K=int(NK[1])
Hlis=list(map(int,input().split()))
ans=0

if K>=N:
    print(0)
else:
    for i in range(N-K):
        ans+=Hlis[Hlis.index(min(Hlis))]
        Hlis[Hlis.index(min(Hlis))]=10**9
    print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

h.sort(reverse = True)

if k <= len(h):
    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 = [int(x) for x in input().split()]
sorted_h = sorted(h, reverse=True)

for i in range(k):
    if len(sorted_h) > 0:
        sorted_h.pop(0)
    else:
        break
print(sum(sorted_h))

Submission status: Time Limit Exceeded

Solution code:
import sys
a = input().split()  
b= input().split()
bb = [int(s) for s in b]
for _ in range(0,int(a[1])):
 try:
  k=max(bb)
  bb.remove(int(k))
 except:
  pass
 #print(max(bb))
 #print(bb)
print(sum(bb))
#print(bb)

Submission status: Time Limit Exceeded

Solution code:
n,k=map(int, input().split())
l=list(map(int, input().split()))
if k>=n:
    print("0")
    exit(0)

for i in range(k):
    l.remove(max(l))

print(sum(l))

Submission status: Time Limit Exceeded

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

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

for i in range(K):
  if len(li) == 0:
    break
  li.remove(max(li))
  
print(sum(li))

Submission status: Time Limit Exceeded

Solution code:
n, k = map(int, input().split())
li = list(map(int, input().split()))
li_a = sorted(li)
if k == 0:
  print(sum(li_a))
elif k >= n:
  print(0)
else:
  for i in range(k):
    a = li_a[-1]
    li_a.remove(a)
  print(sum(li_a))

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:
    if K==0:
        print(sum(H))
    else:
        for i in range(K):
            H=sorted(H)
            H.pop(-1)
        print(sum(H))

Submission status: Time Limit Exceeded

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

    if n <= k:
        print(0)
    elif k > int((n - 1) /2):
        sum_ = sum(a)
        for i in range(n - k):
            a.remove(min(a))
        print(sum_ - sum(a))
    else:
        for i in range(k):
            a.remove(max(a))

        print(sum(a))


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
HK = list(map(int, input().split()))
M = list(map(int, input().split()))

M.sort(reverse=True)

k = HK[1]

while k > 0:
    if (len(M) == 0):
        break
    M.pop(0)
    k -= 1

damage = 0
for i in range(len(M)):
    damage += M[i]

print(damage)

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=sorted(H)
        H.pop(-1)
    print(sum(H))

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8

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

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

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
N, M = map(int, input().split())
count=0
flag=True

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



if N>=M:
    for i in range(M):
        x1=np.argmax(A)
        x1=A.pop(x1)


    print(sum(A))
else:
    print(0)

Submission status: Time Limit Exceeded

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:
  for i in range(K):
    
    maxh=max(H)
    H.remove(maxh)
    
  print(sum(H))

Submission status: Time Limit Exceeded

Solution code:
kazu, hissatu = map(int,input().split())
hairetu = list(map(int,input().split()))

toru = kazu-hissatu

if toru<=0:
  print(0)
else:
  for i in range(hissatu):
    hairetu.remove(max(hairetu))
  print(sum(hairetu))

Submission status: Time Limit Exceeded

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

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 h:
        if k != 0:
            h.remove(max(h))
            k -= 1
            
    print(sum(h))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
NK=input().split()
N=int(NK[0])
K=int(NK[1])
Hlis=list(map(int,input().split()))

if K>=N:
    print(0)
else:
    for i in range(K):
        Hlis[Hlis.index(max(Hlis))]=0
    print(sum(Hlis))

Submission status: Time Limit Exceeded

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

b.sort(reverse=True)
ans = 0

while k > 0:
    if n == 0:
        break
    else:
        b.pop(0)
        k -= 1
        n -= 1

if n == 0:
    print('0')
else:
    print(sum(b))

Submission status: Time Limit Exceeded

Solution code:
N,K = map(int,input().split())
H = list(map(int,input().split()))
if K <= len(H):
  for i in range(K):
    H.pop(H.index(max(H)))
  print(sum(H))
else:
  print(0)

Submission status: Time Limit Exceeded

Solution code:
n,k = map(int,input().split())
a = sorted(list(map(int,input().split())),reverse=True)
summ = 0
if k > 0 and k < n:
    for i in range(k):
        del a[0]
elif n <= k:
    a = []
for i in range(len(a)):
    summ += a[i]
print(summ)

Submission status: Time Limit Exceeded

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

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_h = h.index(max(h))
  h[max_h] = 0
cnt = sum(h)
print(cnt)

Submission status: Time Limit Exceeded

Solution code:
data = input().split()
monsters = int(data[0])
smash = int(data[1])

mon_str = input().split()
mon_str = [int(b) for b in mon_str]
count = 0

for i in range(smash):
    try:
        enemy = mon_str.index(max(mon_str))
        del mon_str[enemy]
    
    except ValueError:
        pass
print(sum(mon_str))

Submission status: Time Limit Exceeded

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

if k >= len(hp_list):
    print(0)
    sys.exit()

for del_num in range(k):
    del hp_list[0]
print(sum(hp_list))

Submission status: Time Limit Exceeded

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

H = sorted(H, reverse=True)
while (K > 0) and (len(H) > 0):
    H.pop(0)
    K -= 1
print(sum(H))

Submission status: Time Limit Exceeded

Solution code:
a=input()
N,K=int(a.split()[0]),int(a.split()[1])
b=input().split()
list=list(map(int, b))

if (K>=len(list)):
  print(0)
else:
  for i in range(K):
    list.remove(max(list))
  print(sum(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:
dummy = list(map(int, input().split(" ")))
N = dummy[0]
K = dummy[1]

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

count = 0
while(count < K):
    max = -1
    max_i = -1
    for i in range(N):
        if(H[i] > max):
            max = H[i]
            max_i = i
    H[max_i] = 0
    count += 1
print(sum(H))

Submission status: Time Limit Exceeded

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

H.sort(reverse=True)

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

Submission status: Time Limit Exceeded

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

a.sort(reverse=True)
attack = 0
#print(min(c[1],c[0]))

for i in range(min(c[1],c[0])):
  a.pop(0)

#print(a)
for i in range(c[0]-c[1]):
  attack += a[i]

print(attack)

Submission status: Time Limit Exceeded

Solution code:

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

h.sort(reverse=True)

for i in range(k):
    h.pop(0)
    
    if h == []:
        break

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

Submission status: Time Limit Exceeded

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

ans = 0
for i in range(n-k):
  ans += h2[0]
  del h2[0]
  
print(ans)

Submission status: Time Limit Exceeded

Solution code:
a = list(map(int,input().split()))
N = a[0]
K = a[1]
H = list(map(int,input().split()))
H.sort(reverse=True)
ans = 0
if K >= N:
    print(0)
else:
    for i in range(K):
        b = H.pop(0)
    ans = sum(H)
    print(ans)

Submission status: Time Limit Exceeded

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

  if li != kara:
    for j in li:
      ans += j

  print(ans)

Submission status: Time Limit Exceeded

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

for _ 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())
List = [int(x) for x in input().split()]


for i in range(K):
    if not List:
        print('0')
        exit()
    List.remove(max(List))

print(sum(List))

Submission status: Time Limit Exceeded

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

H = sorted(H, reverse=True)
if k >= n:
  print(0)
  sys.exit()
for i in range(k):    
  H.pop(0)
cnt = 0
for h in H:
  cnt += h
print(cnt)

Submission status: Time Limit Exceeded

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

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):
        index=H.index(max(H))
        H.pop(index)
    print(sum(H))

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)
else:
  for i in range(K):
    Hmax = max(H)
    H.remove(Hmax)
  print(sum(H))

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
import sys
input = sys.stdin.readline


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

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

Submission status: Time Limit Exceeded

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

aaa = list(map(int, input().strip().split()))
h = sum(aaa)

for i in range(a):
  maxat = max(aaa)
  h -= maxat

if h <= 0:
  h = 0
print(h)

Submission status: Time Limit Exceeded

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

sort_h_list = sorted(h_list, reverse=True)
sort_h_list_length = len(sort_h_list)

for i in range(K):
    if i >= sort_h_list_length:
        break
    sort_h_list.pop(0)

print(sum(sort_h_list))

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

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

for i in range(K):
    H[np.argmax(H)] = 0
print(sum(H))

Submission status: Time Limit Exceeded

Solution code:
n=list(map(int,input().split()))
m=list(map(int,input().split()))
for i in range(n[1]):
  m.remove(max(m))
  if(len(m)==0):
    break
print(sum(m))

Submission status: Time Limit Exceeded

Solution code:
# import numpy as np
# import math
# import copy
# from collections import deque
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(10000)


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

    res = 0
    isNotEmpty = True

    for i in range(K):
        if H == []:
            isNotEmpty = False
            break
        temp = max(H)
        H.remove(temp)

    if isNotEmpty:
        res += sum(H)

    print(res)



main()

Submission status: Time Limit Exceeded

Solution code:
N, K = [int(i) for i in input().rstrip().split(' ')]
H = [int(i) for i in input().rstrip().split(' ')]
H.sort(reverse=True)
for hit in range(K):
    if H: H.pop(0)
print(sum(H))

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8

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

while k>0:
    if h:
        h.remove(max(h))
        k-=1
    elif not h:
        break

if h:
    print(sum(h))
elif not h:
    print(0)

Submission status: Time Limit Exceeded

Solution code:
a = list(map(int,input().split()))
N = a[0]
K = a[1]
H = list(map(int,input().split()))
H.sort(reverse=True)
ans = 0
if K >= N:
    print(0)
else:
    for i in range(K):
        b = H.pop(0)
    for i in range(len(H)):
        ans += H[i]
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
n, k = map(int, input().split())
li = list(map(int, input().split()))
if k >= 1 and k < n:
  for i in range(k):
    li.remove(max(li))
  print(sum(li))
elif k == 0:
  print(sum(li))
elif k >= n:
  print(0)

Submission status: Time Limit Exceeded

Solution code:
# coding:UTF-8

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

count = 0

for k in range(0, K):
    health[health.index(max(health))] = 0

print(sum(health))

Submission status: Time Limit Exceeded

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

h = sorted(h, reverse=True)
is_zero = False
for i in range(k):
    try:
        del h[0]
    except:
        is_zero = True
        break
if is_zero:
    print(0)
else:
    print(sum(h))

Submission status: Time Limit Exceeded

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

ans = 0
for i in range(n-k):
  ans += min(h)
  h.remove(min(h))
  
print(ans)

Submission status: Time Limit Exceeded

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

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

for i in range(K):
    mn = max(H)
    H.remove(mn)

sm = sum(H)

print(sm)

Submission status: Time Limit Exceeded

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) #多い順
for i in range(K):
    if Monsters != []:
        Monsters.remove(Monsters[0])
res += sum(Monsters)
print(res)

Submission status: Time Limit Exceeded

Solution code:
A = list(map(int , input().split()))
B = list(map(int , input().split()))
if A[0] < A[1]:
    print(0)
else:
    B.sort(reverse=True)
    for i in range(A[1]):
        B.remove(max(B))
    print(sum(B))

Submission status: Time Limit Exceeded

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:
    for _ in range(k):
        hl_s.pop(0)
    print(sum(hl_s))

Submission status: Time Limit Exceeded

Solution code:
n,k=map(int, input().split())
l=list(map(int, input().split()))
if k>=n:
    print("0")
    exit(0)

t=n-k
sum=0
for i in range(t):
    m=min(l)
    sum=sum+m
    l.remove(m)

print(sum)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
import sys
n,k=map(int, input().split())
h=list(map(int, input().split()))
b =sorted(h, reverse=True)
#必殺技の消費
for i in range(0,k):
    if len(b) != 0:
        b.pop(0)
    else:
        print(0)
        sys.exit()

#攻撃回数
print(sum(b))

Submission status: Time Limit Exceeded

Solution code:
N,K = map(int, input().split())
H = list(map(int, input().split()))
 
H.sort(reverse=True)
 
K = min(K, len(H))
for k in range(K):
    H.pop(0)
 
print(sum(H))

Submission status: Time Limit Exceeded

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,reverse=True)

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

Submission status: Time Limit Exceeded

Solution code:
a, b = map(int, input().split())
table = list(map(int, input().split()))
table.sort(reverse=True)
if b < len(table):
    for x in range(0, b):
        table.pop(0)
    print(sum(table))
else:
    print(0)

Submission status: Time Limit Exceeded

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

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

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

for _ in range(K):
    H.pop(0)

print(sum(H))

Submission status: Time Limit Exceeded

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

    if n <= k:
        print(0)
    else:
        for i in range(k):
            a.remove(max(a))

        print(sum(a))


if __name__ == '__main__':
    main()

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.sort(reverse=True)
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 = list(map(int, input().split()))
H.sort()
for i in range(K):
    H = H[:-1]
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:
    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=map(int,input().split())

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

H.sort(reverse=True)

for i in range(K):
    try:
        H.pop(0)
    except:
        pass

print(sum(H))

Submission status: Time Limit Exceeded

Solution code:
n,k=map(int,input().split())
H=list(map(int,input().split()))
for _ in range(k):
    if not H:
        break
    H.pop(H.index(max(H)))
print(sum(H))

Submission status: Time Limit Exceeded

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

while k > 0:
    h = h[:-1]
    k -= 1

ans += sum(h)

print(ans)

Submission status: Time Limit Exceeded

Solution code:

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

        i = 0

        while i < k and len(monsters) > 0:
            monsters.pop(0)
            i += 1

        ans = 0

        for monster in monsters:
            ans += monster

        return ans


sol = Solution()

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

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