Problem:


Score : 300 points

Problem Statement

Fennec is fighting with N monsters.

The health of the i-th monster is H_i.

Fennec can do the following two actions:

Attack: Fennec chooses one monster. That monster's health will decrease by 1.

Special Move: Fennec chooses one monster. That monster's health will become 0.

There is no way other than Attack and Special Move to decrease the monsters' health.

Fennec wins when all the monsters' healths become 0 or below.

Find the minimum number of times Fennec needs to do Attack (not counting Special Move) before winning when she can use Special Move at most K times.

Constraints

1 \leq N \leq 2 \times 10^5

0 \leq K \leq 2 \times 10^5

1 \leq H_i \leq 10^9

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N K
H_1 ... H_N

Output

Print the minimum number of times Fennec needs to do Attack (not counting Special Move) before winning.

Sample Input 1

3 1
4 1 5

Sample Output 1

5

By using Special Move on the third monster, and doing Attack four times on the first monster and once on the second monster, Fennec can win with five Attacks.

Sample Input 2

8 9
7 9 3 2 3 8 4 6

Sample Output 2

0

She can use Special Move on all the monsters.

Sample Input 3

3 0
1000000000 1000000000 1000000000

Sample Output 3

3000000000

Watch out for overflow.



Sample input:
3 1
4 1 5


Sample output:
5

Submission status: Accepted

Solution code:
import sys, bisect, math, itertools, string, queue, copy
# import numpy as np
# import scipy
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush
# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input()) # n=1
def inpm(): return map(int,input().split()) # x=1,y=2
def inpl(): return list(map(int, input().split())) # a=[1,2,3,4,5,...,n]
def inpls(): return list(input().split())  # a=['1','2','3',...,'n']
def inplm(n): return list(int(input()) for _ in range(n)) # x=[] 複数行
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return sorted([list(map(int, input().split())) for _ in range(n)]) # [[1,1,1,1],[2,2,2,2],[3,3,3,3]] 
def graph():
    n=inp()
    g=[[] for _ in range(n)]
    for i in range(n):
        a = inp()
        a -= 1
        g[i].append(a)
        g[a].append(i)
    return n,g

def main():
    n,k = inpm()
    a = inpl()
    a.sort()
    if n <= k:
        print(0)
        return
    ans = 0
    for i in range(n-k):
        ans += a[i]
    print(ans)    
    
if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

l = sorted([int(i) for i in input().split()])

ans = 0
if n <= k:
    print(0)
else:
    for i in range(n-k):
        ans += l[i]
        
    print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!

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

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

H.sort()

for _ in range(min(K,len(H))):
    H.pop(-1)
    
print(sum(H))

Submission status: Accepted

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

A.sort(reverse=True)

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

Submission status: Accepted

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

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

Submission status: Accepted

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

H.sort()

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

Submission status: Accepted

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  n,k=LI()
  l=LI()

  l.sort(reverse=True)

  ans=0
  for x in l:
    if k>0:
      k-=1
    else:
      ans+=x

  return ans

# main()
print(main())

Submission status: Accepted

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

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

H.sort(reverse=True)

print(sum(H[K:]))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

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

H.sort()
for i in range(n-k):
    count+=(H[i])
print(count)

Submission status: Accepted

Solution code:

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

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

H.sort()

if N <= K:
    print (0)

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

Submission status: Accepted

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


if __name__ == '__main__':
    main()

# import sys
#
# sys.setrecursionlimit(10 ** 7)
#
# input = sys.stdin.readline
# rstrip()
# int(input())
# map(int, input().split())

Submission status: Accepted

Solution code:
def examA():
    H,A = LI()
    ans = (H-1)//A+1
    print(ans)
    return

def examB():
    H, N = LI()
    A = LI()
    if H>sum(A):
        print("No")
    else:
        print("Yes")
    return

def examC():
    N, K = LI()
    H = LI()
    H.sort()
    ans = sum(H[:max(0,N-K)])
    print(ans)
    return

def examD():
    ans = 0
    print(ans)
    return

def examE():
    ans = 0
    print(ans)
    return

def examF():
    ans = 0
    print(ans)
    return

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
alphabet = [chr(ord('a') + i) for i in range(26)]

if __name__ == '__main__':
    examC()

"""

"""

Submission status: Accepted

Solution code:
N,K = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
A.sort(reverse=True)
B = 0
ans = 0
for a in A:
    if B<K:
        B+=1
    else:
        ans += a

print(ans)

Submission status: Accepted

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

h.sort(reverse=True)

ans = sum(h[k:])
print(ans)

Submission status: Accepted

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

H.sort()
ans=0
for i in range(N-K):
    ans+=H[i]
print(ans)

Submission status: Accepted

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

print(sum(H[K:]))

Submission status: Accepted

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

if N <= K:
  print(0)
else:
  su = 0
  for i in H[K:]:
    su += i
  print(su)

Submission status: Accepted

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

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

Submission status: Accepted

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

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

print(res)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys, math
def input():
    return sys.stdin.readline()[:-1]
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial
from fractions import gcd
e = enumerate

sys.setrecursionlimit(10**7)
N, K = map(int, input().split())
H = list(map(int, input().split()))

H.sort(reverse=True)

print(sum(H[K:]))

Submission status: Accepted

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

Submission status: Accepted

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

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

need = sum(h[:n - k])

print(need)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,K = map(int,input().split())
H = list(map(int,input().split()))
H.sort(reverse=True)
ans = 0
for h in H:
    if K:
        K -= 1
    else:
        ans += h
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

H = sorted(H)[::-1]

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

Submission status: Accepted

Solution code:
n, k = [ int(v) for v in input().split() ]
monster = [ int(v) for v in input().split() ]
monster.sort(reverse = True)
k = min(k, n)

for i in range(k):
    monster[i] = 0
print(sum(monster))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    N, K = map( int, input().split())
    H = list( map( int, input().split()))
    if N <= K:
        print("0")
        return
    H.sort( reverse=True)
    print( sum( H[K:]))
if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

from collections import deque, defaultdict
import itertools as ite
import sys
import math
from decimal import *

sys.setrecursionlimit(1000000)

INF = 10 ** 18
MOD = 10 ** 9 + 7

N, K = map(int, raw_input().split())
A = sorted(map(int, raw_input().split()))
ans = 0
for i in range(N - K):
    ans += A[i]
print ans

Submission status: Accepted

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

h = sorted(h)

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

Submission status: Accepted

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

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

Submission status: Accepted

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

print(sum(H[K:]))

Submission status: Accepted

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

lst1.sort(reverse=True)

del lst1[:k]

print(sum(lst1))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n, k = na()
k = min(k, n)
h = na()
h.sort()
print(sum(h[0:n-k]))

Submission status: Accepted

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

h.sort()
h.reverse()

for i in range(min(k,n)):
    h[i] = 0
print(sum(h))

Submission status: Accepted

Solution code:
import sys

input = sys.stdin.readline


def main():
    N, K = [int(x) for x in input().split()]
    H = [int(x) for x in input().split()]
    H.sort(reverse=True)

    print(sum(H[K:]))

    
    
    

if __name__ == '__main__':
    main()

Submission status: Accepted

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

a = sorted(a, reverse = True)
cnt = 0
for i in range(n):
    if i < k:
        continue
    else:
        cnt += a[i]
print(cnt)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
INF = float("inf")


def solve(N: int, K: int, H: "List[int]"):
    H.sort(reverse=True)
    if N > K:
        tot = sum(H[K:])
    else:
        tot = 0
    print(tot)
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    H = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, K, H)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

H.sort()
print sum(H[:max(0, N-K)])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
from collections import defaultdict, deque
import bisect
from heapq import *
from math import factorial, ceil, floor
from collections import defaultdict
import itertools
sys.setrecursionlimit(200000)
input = sys.stdin.readline

# N, M, = map(int, input().split())
# N = int(input())
# L = [int(v) for v in input().split()]
# L = [[int(v) for v in input().split()] for _ in range(N)]
# L = [int(input()) for _ in range(N)]
# L = [list(input().strip())  for _ in range(N)]
# S = input().strip()

H, N, = map(int, input().split())
L = [int(v) * -1 for v in input().split()]

L.sort()

ans = 0
for i in range(N, H):
    ans += L[i] * -1

print(ans)

Submission status: Accepted

Solution code:
import sys
import fractions
import math
MAX_INT = int(10e12)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

H, K = IL()
a = IL()
a.sort(reverse=True)
num = sum(a[K:])

print(num)

Submission status: Accepted

Solution code:
# ABC153c


def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10 ** 6)

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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
# 体力でかいやつに使ったほうがいいよね
n, k = map(int, input().split())
arr = sorted(list(map(int, input().split())))[::-1]
if k >= n:
    print(0)
    exit()
print(sum(arr[k:]))

Submission status: Accepted

Solution code:
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False
"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""

h,a = m()

b = l()

b.sort(reverse = True)

co = 0
for i in range(h):
    if a > 0:
        a -= 1
    else:
        co += b[i]

print(co)

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
def input(): return sys.stdin.readline().rstrip()

def main():
    N,K=map(int,input().split())
    H=list(map(int,input().split()))
    H.sort(reverse=True)
    print(sum(H[K:]))

if __name__ == '__main__':
    main()

Submission status: Accepted

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

print(sum(A[K:]))

Submission status: Accepted

Solution code:
import sys
import math
from collections import defaultdict

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N,num):
    if N<=0:
        return [[] for _ in range(num)]
    elif num==1:
        return [I() for _ in range(N)]
    else:
        read_all = [tuple(II()) for _ in range(N)]
        return map(list, zip(*read_all))

#################

N,K = II()
H = III()

H.sort(reverse=True)
if K>=N:
    print(0)
else:
    print(sum(H[K:]))

Submission status: Accepted

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

Submission status: Accepted

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

H.sort()
print(sum(H[:max(0, N - K)]))

Submission status: Accepted

Solution code:
import os
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353


N, K = list(map(int, sys.stdin.buffer.readline().split()))
H = list(map(int, sys.stdin.buffer.readline().split()))

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

Submission status: Accepted

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

Submission status: Accepted

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

import sys
sys.setrecursionlimit(300000)


def solve(N: int, K: int, H: "List[int]"):
    H.sort(reverse=True)
    a = sum(H[K:])
    ret = a
    print(ret)
    return

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    H = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, K, H)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def inpl():
    return list(map(int, input().split()))


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

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

Submission status: Runtime Error

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

H.sort(reverse = True)
sum = 0

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

Submission status: Runtime Error

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

H.sort(reverse = True)
sum = 0

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

print(sum)

Submission status: Runtime Error

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

enemy.sort(reverse=True)

for x in range(k):
  enemy[x] = 0
  
print(sum(enemy))

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

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

Submission status: Runtime Error

Solution code:
N,K = map(int,input().split())
enemys = list(map(int,input().split()))
enemys = sorted(enemys,reversed = True)
if K >= len(enemys):
  print(0)
else:
  enemys = enemys[K+1:]
  print(sum(enemys))

Submission status: Runtime Error

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

if K > N:
    print(0)
    exit()

for i in range(K):
    H.pop(i)
    
for i in range(len(H)):
    SUM = SUM + H[i]

print(SUM)

Submission status: Runtime Error

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

ans = sum(H)

for n in range(1,min(N+1,K+1)):
    ans -= sorted(H)[-n]

print(ans)]

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
a,b=input().split()
a=int(a)
b=int(b)
c=list(map(int,input().split()))
c.sort()
d=sum(c)
e=0
for i in range(b):
  e=e+c[-b]
print(d-2*e)

Submission status: Runtime Error

Solution code:
a,b=input().split()
c=list(map(int,input().split()))
c.sort()
d=sum(c)
e=0
for i in range(b):
  e=e+c[-b]
print(d-2*e)

Submission status: Runtime Error

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

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

H.sort()
H.reverse()


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

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

print(c)

Submission status: Runtime Error

Solution code:
N, K = map(int, input().split())
H = list(map(int, input().split()))
H.sort()
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(reverce=True)
ans = 0
if(k>=n):
  ans = 0
else:
  for i in range(k,n):
    ans += h[i]
print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
number = list(map(int,input().split()))
score = list(map(int,input().split()))
score.sort()
answer = 0
for i in range(number[1]):
    score[number[0]-1-i] = 0
for j in range(number[0]):
    answer += score[j]
print(answer)

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:
  k=n

for i in range(k):
  h[i]=0

sum_=0
for hh in range(h):
  sum_+=hh
print(sum_)

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

sum_=0
for hh in h:
  sum_+=hh
print(sum_)

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

sum_=0
for hh in range(h):
  sum_+=hh
print(sum_)

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

N, K = map(int, next(sys.stdin.buffer).split())
H = sorted(map(int, next(sys.stdin.buffer).split()))

print(sum(H[:K])

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N,K = map(int,input().split())
ls = list(map(int,input().split()))
ls.sort(reverse=True)
for i in range(K):
    ls.pop(0)

print(sum(ls))

Submission status: Runtime Error

Solution code:
def main():
    n, k = map(int, input().split())
    h = [int(x) for x in input().split()]
    h_s = sorted(h)
    if len(h_s) <= k:
        ans = 0
    else:
        for _ in range(k):
            h_s.pop()
        ans = sum(h_s)
    print(ans)

if __name__ == '__main__':
    main(

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N, K = map(int,input().split())
H = list(map(int,input().split()))
new_H = sorted(H,reverse=True)
A = 0
for i in range(K):
  del new_H[0]
for i in range(len(new_H)):
  A += new_H[i]
print(A+K)

Submission status: Runtime Error

Solution code:
N, K = map(int,input().split())
H = list(map(int,input().split()))
new_H = sorted(H,reverse=True)
A = 0
for i in range(K):
  del.new_H[0]
for i in range(len(new_H)):
  A += new_H[i]
print(A+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):
  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(reverse=True)
for i in range(k):
  H[i] = 0
  print(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)
ans = 0
if k == 0 :
    ans = sum(h)
else :
    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()
sumh = 0
if k == 0 :
    print(sum(h))
else :
    for i in range(1,k+1):
        sumh += h[i*-1]
    print(sum(h)-sumh)

Submission status: Runtime Error

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

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

h.sort()
sumh = 0
for i in range(1,k+1):
    sumh += h[i*-1]
print(sum(h)-sumh)

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())
mon=list(map(int,input().split()))
mon.sort(reverse=True)
for i in range(k):
  mon.pop(0)
print(sum(mon))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import sys

N, K = (int(x) for x in input().split())
H = list(map(int, input().split()))
ans=0

if K>=N:
  print(0)
  sys.exit(0)
  
H.sort(reverse=True)
for i in range(K):
  del H[i]
for i in range(len(H)):
  ans+=H[i]
print(ans)

Submission status: Runtime Error

Solution code:
import sys

N, K = (int(x) for x in input().split())
H = list(map(int, input().split()))
ans=0

if K>=N:
  print(0)
  sys.exit(0)
  
H.sort(reverse=True)
for i in range(K):
  del H[i]
for i in range(N-K):
  ans+=H[i]
print(ans)

Submission status: Runtime Error

Solution code:
N,A=map(int,input().split())
B=sorted(list(map(int,input().split())))
for j in range(A):
    B.pop()
print(sum(B))

Submission status: Runtime Error

Solution code:
N,A=map(int,input().split())
B=sorted(list(int(input()) for i n range(N)))
for j in range(A):
    B.pop()
print(sum(B))

Submission status: Runtime Error

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

H.soat(reverse=True)

H=H[K:]

H_cumsum=[0]
H_sum_=0
for n in range(len(H)):
    H_sum_=H_sum_+H[n]
    H_cumsum.append(H_sum_)
print(H_sum_)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

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.pop()
cont=0
for i in range(len(H)):
  while H[i]>0:
    H[i]-=1
    cont+=1
print(cont)