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:
#!/usr/bin/env python3
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def sum_of_arithmetic_progression(s, d, n):
    return n * (2 * s + (n - 1) * d) // 2


def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


def lcm(a, b):
    g = gcd(a, b)
    return a / g * b


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

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


def main():
    solve()


if __name__ == '__main__':
    main()

Submission status: Accepted

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

H.sort(reverse=True)

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

print(s)

Submission status: Accepted

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

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-K):
    ans+=H[K+i]
print(ans)

Submission status: Accepted

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

hitpoints.sort(reverse=True)
del hitpoints[:k]

ans = 0
for i in hitpoints:
    ans += i

print(ans)

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

I = sorted(H,reverse=True)

if len(H) <= K:
    print(0)
elif K == 0:
    print(sum(H))
else:
    for i in range(K):
        I[i] = 0
    print(sum(I))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
#a = [input() for _ in range(n)]

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: Accepted

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

main()

Submission status: Accepted

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

Submission status: Accepted

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

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

h.sort()

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

Submission status: Accepted

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

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

h.sort()
attack = 0
for i in range(n-k):
    attack = attack + h[i]
print(attack)

Submission status: Accepted

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

Submission status: Accepted

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

h.sort()
k = min(n,k)
for _ in range(k):
    h.pop()

print(sum(h))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

for i in range(k):
  if not nl:
    break
  else:
  	nl.pop()
if not nl:
  print("0")
else:
  print(sum(nl))

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
H = map(int, input().split())
if K >= N:
    print(0)
    exit()

H = list(H)
H.sort()
print(sum(x for x in H[0 : N - K]))

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def mapt(fn, *args):
    return tuple(map(fn, *args))

def main():
    n, k = mapt(int, (input().split(" ")))
    a = sorted(mapt(int, input().split(" ")))
    if k >= len(a): print(0); exit()
    while k > 0:
        a.pop()
        k -= 1
    print(sum(a))
    
main()

Submission status: Accepted

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

hn.sort(reverse = True)
if len(hn) > k:
  print(sum(hn[k:]))
else :
  print(0)

Submission status: Accepted

Solution code:
number = list(map(int,input().split()))
score = list(map(int,input().split()))
score.sort()
answer = 0
if number[1] > number [0]:
    number[1] = number[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: Accepted

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

Submission status: Accepted

Solution code:
import bisect,collections,copy,heapq,itertools,math,numpy,string
import sys
sys.setrecursionlimit(10**7)

def S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())

def main():
    N,K = LI()
    H = sorted(LI(),reverse=True)
    H_removed = H[K:]
    print(sum(H_removed))


main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

h.sort(reverse=True)

if k>n:
  k=n

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

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

Submission status: Accepted

Solution code:
import sys

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

if K:
  H.sort()
  print(sum(H[:-K]))
else:
  print(sum(H))

Submission status: Accepted

Solution code:
import sys

N, K = map(int, sys.stdin.readline().rstrip().split())
H = [int(x) for x in sys.stdin.readline().rstrip().split()]

H.sort()
# print(H[:-K])
if K == 0:
    print(sum(H))
else:
    print(sum(H[:-K]))

Submission status: Accepted

Solution code:
a,b=map(int,input().split())
l=list(map(int,input().split()))
z=0
l=sorted(l)
for i in range(a-b):
  z+=l[i]
print(z)

Submission status: Accepted

Solution code:
a,b=map(int,input().split())
l=sorted(list(map(int,input().split())))
z=0
for i in range(a-b):
  z+=l[i]
print(z)

Submission status: Accepted

Solution code:
N, K = list(map(lambda n: int(n), input().split(" ")))
HP = list(map(lambda hp: int(hp), input().split(" ")))
HP.sort(reverse=True)

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

Submission status: Accepted

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

Submission status: Accepted

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

sort_H = sorted(H, reverse=True)

ans = sum(sort_H[K:])

print(ans)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
ins = lambda: input().rstrip()
ini = lambda: int(input().rstrip())
inm = lambda: map(int, input().split())
inl = lambda: list(map(int, input().split()))

n, k = inm()
a = sorted(inl())
print(sum(a[:n-k]) if n > k else 0)

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
from fractions import gcd
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

n,k = inpm()
H = inpl()

H.sort()
H.reverse()

print(sum(H[k:]))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
if __name__ == '__main__':
    N, K = map(int, input().split())
    H = list(map(int, input().split()))
    H = sorted(H)[::-1]
    cnt = 0
    for h in H:
        if K>0:
            K -= 1
        else:
            cnt += h
    
    print(cnt)

Submission status: Accepted

Solution code:
#https://atcoder.jp/contests/abc153/tasks/abc153_c
N,K =map(int,input().split())
M_List = sorted(list(map(int,input().split())))
if K == 0:
    print(sum(M_List))
elif N<=K:
    print(0)
else:
    print(sum(M_List[:K*(-1)]))

Submission status: Accepted

Solution code:
a,b=map(int,input().split())
A=[int(x) for x in input().split()]
A.sort()
if a>=b:
  print(sum(A[:(a-b)]))
else:
  print(0)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
arr = list(map(int, input().split()))
arr.sort()
m = min(n, m)
while m > 0:
	arr.pop()
	m -= 1
ans = 0
for x in arr:
	ans += x
print(ans)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# Generated by https://github.com/kyuridenamida/atcoder-tools
from typing import *
import collections
import functools
import itertools
import math
import sys

INF = float('inf')


def solve(N: int, K: int, H: "List[int]"):
    return sum(sorted(H)[:-K]) if K != 0 else sum(H)


def main():

    sys.setrecursionlimit(10 ** 6)

    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]"
    print(f'{solve(N, K, H)}')


if __name__ == '__main__':
    main()

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

Submission status: Accepted

Solution code:
n,k,*hh = map(int, open(0).read().split())

hh.sort(reverse=True)

print(sum(hh[k:]))

Submission status: Accepted

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

c=0
P.sort( reverse=True )

if k>len(P):
    k=len(P)
for i in range(k):
    c+=1    

ans = sum(P[c:])

print(ans)

Submission status: Accepted

Solution code:
n,k = map(int,input().split())
h = [int(s) for s in input().split()]
h.sort(key=int)
for _ in range(min(k,len(h))):del h[-1]
print(sum(h))

Submission status: Accepted

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

print(sum(h[k:]))

Submission status: Accepted

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

Submission status: Accepted

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

if N <= K:
    print(0)
else:
    H = sorted(H)
    ans = 0
    for i in range(N-K):
        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)
for i in range(min(k,len(h))):
    h[i]=0
print(sum(h))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

if '__main__' == __name__:
    resolve()

Submission status: Accepted

Solution code:
N, K = list(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())))[::-1]
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)

h1 = h[k:n]
print(sum(h1))

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
h=[int(x) for x in input().rstrip().split()]
h.sort(reverse=True)

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

Submission status: Accepted

Solution code:
import sys


def solve(n, k, h):
    if n <= k:
        return 0
    else:
        return sum(h[: n - k])


def main():
    input = sys.stdin.buffer.readline
    n, k = map(int, input().split())
    h = sorted(list(map(int, input().split())))
    print(solve(n, k, h))


if __name__ == "__main__":
    main()

Submission status: Accepted

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

if len(H) <= k:
    ans = 0
else:
    H.sort()
    r = H
    if k != 0:
        r = H[:-k]
    ans = sum(r)

print(ans)

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
h = [int(i) for i in input().split()]
new_h = sorted(h)[:n - k]
if n > k:
    print(sum(new_h))
else:
    print(0)

Submission status: Accepted

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

H = sorted(H)

if N < K:
    K = N

for i in range(K):
    del[H[-1]]

print(sum(H))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,K=map(int,input().split())
List = list(map(int, input().split()))
List.sort(reverse = True)
res = 0
for i in range(N):
  if i <= K-1:
    pass
  else:
    res += List[i]
print(res)

Submission status: Accepted

Solution code:
import math
from math import gcd
INF = float("inf")

import sys
input=sys.stdin.readline
import itertools
from collections import Counter

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


if __name__=="__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

if k != 0:
  del l[-k:]
print(sum(l))

Submission status: Accepted

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

Submission status: Accepted

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

    if K >= len(H):
        print('0')
    else:
        sorted_H = sorted(H)
        alived = N - K
        print(sum(sorted_H[:alived]))

if __name__ == "__main__":
    solve()

Submission status: Accepted

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

Submission status: Accepted

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


if n <= k:
  print(0)
else:
  del a[0:k]
  print(sum(a))

Submission status: Accepted

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


solve()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

print(sum(H[K:]))

Submission status: Accepted

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

h = [0 for _ in range(n)]
h = [int(s) for s in input().split()]

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

print(ans)

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
hp = sorted(list(map(int, input().split())))
for _ in range(min(len(hp), k)):
    del hp[-1]
print(sum(hp))

Submission status: Accepted

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

Submission status: Accepted

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

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:
    ans=0
    for i in range(n-k):
        ans+=h[i]
    print(ans)

Submission status: Accepted

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

a = sorted(list(map(int,input().split())),reverse=True)
del a[0:K]
print(sum(a))

Submission status: Accepted

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

h.sort(reverse=True)
print(sum(h[k:]))

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:

def solve():
    H.sort()
#    print(H)
    if K == 0:
        print(sum(H))
    else:
        print(sum(H[0:-K]))


if __name__ == "__main__":
    N,K = list(map(int, input().split()))
    H = list(map(int, input().split()))
    solve()

Submission status: Accepted

Solution code:
N,K=map(int,input().split())
H=sorted(list(map(int,input().split())),reverse=True)
H=H[K:]
ans=0
if K<N:
  for x in H:
    ans+=x
print(ans)

Submission status: Accepted

Solution code:
a,b=[int(i) for i in input().split()]
c=[int(i) for i in input().split()]
c=sorted(c,reverse=True)
d=sum(c)
for i in range(0,len(c)):
    if(b>0):
        d=d-c[i]
        b=b-1
    else:
        break
print(d)

Submission status: Accepted

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

if n <= k:
    print(0)
    exit()
else:
    for i in h:
        sum += i
print(sum)

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 fennec_vs_monster():
    # 入力
    N, K = map(int, input().split())
    H = list(map(int, input().split()))
    # 体力リストを降順でソート
    H.sort(reverse=True)
    # 体力リストを先頭からK個だけ除外
    H = H[K:]
    # 残りの体力リストを合計
    sum_H = sum(H)
    # 攻撃の回数の最小値
    return sum_H

result = fennec_vs_monster()
print(result)

Submission status: Accepted

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

Submission status: Accepted

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

Hli.sort(reverse = True)
res = 0

for i in range(K,N):
  res += Hli[i]

print(res)

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:
def readinput():
    n,k=map(int,input().split())
    h=list(map(int,input().split()))
    return n,k,h

def main(n,k,h):
    if k>=n:
        return 0
    
    h.sort(reverse=True)
    ans=0
    for i in range(k,n):
        ans+=h[i]
    return ans

if __name__=='__main__':
    n,k,h=readinput()
    ans=main(n,k,h)
    print(ans)

Submission status: Accepted

Solution code:
N,K=map(int,input().split())
H=list(map(int, input().split()))
#Nモンスターの数、K必殺回数（モンスターは体力ゼロになる）、Hモンスターの数と各々の体力
H=sorted(H)
if K>=len(H):
  print(0)
else:
  for i in range(0,K):
    del H[-1]
  result=sum(H)
  print(result)

Submission status: Accepted

Solution code:


def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def solve():
    N, K = read_ints()
    H = read_ints()
    if K >= N:
        return 0
    H.sort(reverse=True)
    return sum(H[K:])


if __name__ == '__main__':
    print(solve())

Submission status: Accepted

Solution code:
n,k=input().split()
n=int(n)
k=int(k)
#print(h,n)
arr=list(map(int,input("\r").strip().split()))[:n] 
arr.sort()
sum=0;
for i in range(0,n-k):
  #  print(arr[i])
    sum+=arr[i]
  
print(sum)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.buffer.readline
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))

n, k = MAP()
h = LIST()
h.sort(reverse=True)

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

Submission status: Accepted

Solution code:
# abc153_c.py
# https://atcoder.jp/contests/abc153/tasks/abc153_c

# C - Fennec vs Monster /
# 実行時間制限: 2 sec / メモリ制限: 1024 MB
# 配点 : 300点

# 問題文
# フェネックは N体のモンスターと戦っています。
# i番目のモンスターの体力は Hiです。
# フェネックは次の 2種類の行動を行うことができます。
#     攻撃：モンスターを 1体選んで攻撃することで、そのモンスターの体力を 1減らす
#     必殺技：モンスターを 1体選んで必殺技を使うことで、そのモンスターの体力を 0にする
# 攻撃と必殺技以外の方法でモンスターの体力を減らすことはできません。
# 全てのモンスターの体力を 0以下にすればフェネックの勝ちです。
# フェネックが K回まで必殺技を使えるとき、モンスターに勝つまでに行う攻撃の回数 (必殺技は数えません) の最小値を求めてください。

# 制約
#     1≤N≤2×105
#     0≤K≤2×105
#     1≤Hi≤109
#     入力中のすべての値は整数である。

# 入力
# 入力は以下の形式で標準入力から与えられる。
# N K
# H1 ... HN

# 出力
# フェネックがモンスターに勝つまでに行う攻撃の回数 (必殺技は数えない) の最小値を出力せよ。

# 入力例 1
# 3 1
# 4 1 5

# 出力例 1
# 5

# 3番目のモンスターに必殺技を使い、1 番目のモンスターに 4 回、2 番目のモンスターに 1 回攻撃を行うことで、攻撃の回数を 5回にできます。

# 入力例 2
# 8 9
# 7 9 3 2 3 8 4 6

# 出力例 2
# 0

# 全てのモンスターに必殺技を使うことができます。

# 入力例 3
# 3 0
# 1000000000 1000000000 1000000000

# 出力例 3
# 3000000000

# オーバーフローに注意してください。


global FLAG_LOG
FLAG_LOG = False


def log(value):
    # FLAG_LOG = True
    # FLAG_LOG = False
    if FLAG_LOG:
        print(str(value))


def calculation(lines):
    # S = lines[0]
    # N = int(lines[0])
    N, K = list(map(int, lines[0].split()))
    values = list(map(int, lines[1].split()))
    # values = list(map(int, lines[2].split()))
    # values = list()
    # for i in range(N):
    #     values.append(int(lines[i]))
    # valueses = list()
    # for i in range(N):
    #     valueses.append(list(map(int, lines[i+1].split())))

    if K >= N:
        result = 0
    else:
        values.sort()
        values = values[::-1]
        for k in range(K):
            values[k] = 0
        result = sum(values)

    return [result]


# 引数を取得
def get_input_lines(lines_count):
    lines = list()
    for _ in range(lines_count):
        lines.append(input())
    return lines


# テストデータ
def get_testdata(pattern):
    if pattern == 1:
        lines_input = ['3 1', '4 1 5']
        lines_export = [5]
    if pattern == 2:
        lines_input = ['8 9', ' 7 9 3 2 3 8 4 6']
        lines_export = [0]
    if pattern == 3:
        lines_input = ['3 0', '1000000000 1000000000 1000000000']
        lines_export = [3000000000]
    return lines_input, lines_export


# 動作モード判別
def get_mode():
    import sys
    args = sys.argv
    global FLAG_LOG
    if len(args) == 1:
        mode = 0
        FLAG_LOG = False
    else:
        mode = int(args[1])
        FLAG_LOG = True
    return mode


# 主処理
def main():
    import time
    started = time.time()
    mode = get_mode()
    if mode == 0:
        lines_input = get_input_lines(2)
    else:
        lines_input, lines_export = get_testdata(mode)

    lines_result = calculation(lines_input)

    for line_result in lines_result:
        print(line_result)

    # if mode > 0:
    #     print(f'lines_input=[{lines_input}]')
    #     print(f'lines_export=[{lines_export}]')
    #     print(f'lines_result=[{lines_result}]')
    #     if lines_result == lines_export:
    #         print('OK')
    #     else:
    #         print('NG')
    # finished = time.time()
    # duration = finished - started
    # print(f'duration=[{duration}]')


# 起動処理
if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# 2020/07/26
# AtCoder Beginner Contest 153 - C

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

# 降順にソート
h.sort()
h.reverse()
ans = 0

for i in range(n):
    # K回まで必殺技を使う
    if i < k:
        continue
    else:
        ans = ans + h[i]

# Output
print(ans)

Submission status: Accepted

Solution code:
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
n,k = readInts()
H = sorted(readInts(),reverse=True)
if n <= k:
    print(0)
else:
    print(sum(H[k:]))

Submission status: Accepted

Solution code:
n,k = map(int, input().split())
H = sorted(list(map(int, input().split())))[::-1]
ans = 0
for h in H:
    if k>0:
        k -= 1
        continue
    ans += h
print(ans)

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inm = lambda: map(int, sys.stdin.readline().split())
inl = lambda: list(inm())
ins = lambda: sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw))

n, k = inm()
H = inl()
H.sort()


def solve():
    if k >= n:
        return 0
    return sum(H[: n - k])


print(solve())

Submission status: Accepted

Solution code:
N,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 = map(int, input().split())
H = list(map(int, input().split()))
H.sort(reverse=True)
print(sum(H[k:]))

Submission status: Accepted

Solution code:
import sys

input = sys.stdin.readline


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

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

    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

if n <= k:
    ans = 0
else:
    ans = sum(h[:n-1*k])

print(ans)