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:
from math import factorial
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate
import sys
import bisect
import string
import math
import time


def I(): return int(input())


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


def S(): return input()


def MS(): return map(str, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


def MS(): return map(str, input().split())


YN = {False: 'No', True: 'Yes'}
MOD = 10**9+7
inf = float('inf')
IINF = 10**10
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']


# show_flg = False
show_flg = True


def main():
    N, K = MI()
    H = LI()
    H = sorted(H, reverse=True)
    ans = 0

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

    for h in H[K:]:
        ans += h

    print(ans)


if __name__ == '__main__':
    main()

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:
#!/usr/bin/env python
# -*- coding: utf-8 -*-


def solve(inp):
    import math
    (N, K) = map(int, inp.readline().strip().split(' '))
    H = list(map(int, inp.readline().strip().split(' ')))

    if K > len(H):
        return "0"

    H = sorted(H)
    H = H[:(N - K)]

    print(sum(H))


def main():
    import sys
    result = solve(sys.stdin)
    if result is not None and result != '':
        print(result)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

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(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:]))


if __name__ == '__main__':
    main()

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
print(sum(h))

Submission status: Accepted

Solution code:
from bisect import *
from collections import *
from itertools import *
import functools
import sys
import math
from decimal import *
from copy import *
from heapq import *
from fractions import *
getcontext().prec = 30
MAX = sys.maxsize
MAXN = 10**5+10
MOD = 10**9+7
spf = [i for i in range(MAXN)]
spf[0]=spf[1] = -1
def sieve():
    for i in range(2,MAXN,2):
        spf[i] = 2
    for i in range(3,int(MAXN**0.5)+1):
        if spf[i]==i:
            for j in range(i*i,MAXN,i):
                if spf[j]==j:
                    spf[j]=i
def fib(n,m):
    if n == 0:
        return [0, 1]
    else:
        a, b = fib(n // 2)
        c = ((a%m) * ((b%m) * 2 - (a%m)))%m
        d = ((a%m) * (a%m))%m + ((b)%m * (b)%m)%m
        if n % 2 == 0:
            return [c, d]
        else:
            return [d, c + d]

def charIN(x= ' '):
    return(sys.stdin.readline().strip().split(x))

def arrIN(x = ' '):
    return list(map(int,sys.stdin.readline().strip().split(x)))

def ncr(n,r):
    num=den=1
    for i in range(r):
        num = (num*(n-i))%MOD
        den = (den*(i+1))%MOD

    return (num*(pow(den,MOD-2,MOD)))%MOD

def flush():
    return sys.stdout.flush()

'''*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*'''
n,k = arrIN()
a = arrIN()
if k>=n:
    print(0)
else:
    a.sort()
    for i in range(k):
        a.pop()
    print(sum(a))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from operator import itemgetter
from math import log10,ceil

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


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
#設定
import sys
input = sys.stdin.buffer.readline

#ライブラリインポート
from collections import defaultdict

con = 10 ** 9 + 7
#入力受け取り
def getlist():
	return list(map(int, input().split()))

#処理内容
def main():
	N, K = getlist()
	H = getlist()
	H = sorted(H)
	ans = 0
	if K >= N:
		print(0)
		return
	
	for i in range(N - K):
		ans += H[i]

	print(ans)

if __name__ == '__main__':
	main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
from collections import defaultdict
from collections import deque
import numpy as np
import heapq
from heapq import heappush, heappop


sys.setrecursionlimit(10 ** 7)

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

H.sort(reverse=True)

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

Submission status: Accepted

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

Submission status: Accepted

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

H.sort(reverse=True)
if len(H) <= 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()))

h = sorted(h,reverse=True)

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
N, K = map(int, input().split(' '))
H = list(map(int, input().split(' ')))
H.sort(reverse=True)
if N <= K:
    print(0)
else:
    print(sum(H[K:]))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

def one_int():
    return int(input())

def one_str():
    return input()

def many_int():
    return list(map(int, input().split()))

N,K = two_int()
H=many_int()

sH=sorted(H)

newK = max(N-K,0)

min_sH = sH[:newK]

print(sum(min_sH))

Submission status: Accepted

Solution code:
import math

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

if N <= K:
	print(0)
else:
	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()))

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

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

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(K):
    if i>=N:
        break
    H[i]=0

print(sum(H))

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)
    h = h[:(n-k)]

    print(sum(h))

Submission status: Accepted

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

Hlist.sort(reverse=True)

if K < N:
    print(sum(Hlist[K:]))
else:
    print(0)

Submission status: Accepted

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


if __name__ == "__main__":
    main()

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N,K = [int(i) for i in input().split()]
H = sorted([int(i) for i in 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)

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

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
N, K, *H = map(int, open(0).read().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())), reverse=True)
if N <= K:
  print(0)
else:
	print(sum(H[K:]))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from sys import stdin

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

H.sort()

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

Submission status: Accepted

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

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

Hs.sort(reverse=True)
ans = sum(Hs[K:])

print(ans)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

N, K = MAP()
A = sorted(LIST(), reverse=1)

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

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

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
from collections import deque

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

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

print(sum(H))

Submission status: Accepted

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

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

for _ in range(k):
    H.pop()
ans = sum(H)
print(ans)

Submission status: Accepted

Solution code:
N, K = [int(i) for i in input().split()]
H = [int(i) for i in input().split()]
H.sort()
ans = 0
if K > 0:
    ans += sum(H[:-K])
else:
    ans += sum(H)
print(ans)

Submission status: Accepted

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

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

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

if N < K:
    K = N

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

print(sum(H))

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:
import queue
import copy
import math
from collections import deque

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

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

sorted_hn = sorted(hn, reverse=True)

rest = sorted_hn[k:]

print(sum(rest))

Submission status: Accepted

Solution code:
from collections import deque

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

Hs.sort(reverse=True)
Hs = deque(Hs)

for i in range(k):
    if len(Hs) == 0:
        print(0)
        exit()
    Hs.popleft()


print(sum(Hs))

Submission status: Accepted

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

sortedH = sorted(H, reverse = True)

attackNum = 0
for i in range(K, N):
    attackNum += sortedH[i]

print(attackNum)

Submission status: Accepted

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

monsters = sorted(H)

if N <= K:
    ans = 0
else:
    ans = sum(monsters[:N - K])

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

if len(h) <= 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())
a_ls = list(map(int, input().split()))
a_ls.sort(reverse =True)
sum_at = 0
for i in range(k, n):
    sum_at+=a_ls[i]
print(sum_at)

Submission status: Accepted

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

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

h.sort()

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

Submission status: Accepted

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

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

for i in range(k, n):
    count += h[i]

print(count)

Submission status: Accepted

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

H = sorted(H, reverse=True)

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
H = [int(x) for x in input().split()]
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 = sorted(H)[::-1]
ans = 0
for k in range(K,N):
    ans += H[k]
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

alist=sorted(alist)
atk=0
#atk+=k
atk+=sum(alist[:max(n-k, 0)])
print(atk)

Submission status: Accepted

Solution code:
# coding: utf-8
N,K=map(int,input().split())
H=list(map(int,input().split()))
H.sort(reverse=True)

L=sum(H[K:])
print(L)

Submission status: Accepted

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

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)

hissatsu = h[:k]
normal = h[k:]

print(sum(normal))

Submission status: Accepted

Solution code:
def solve():
    N, K, *H = map(int, open(0).read().split())
    H.sort(reverse=True)
    ans = sum(H[K:])
    print(ans)


if __name__ == '__main__':
    solve()

Submission status: Accepted

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

Submission status: Accepted

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


if __name__ == "__main__":
    main()

Submission status: Accepted

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

lst.sort()
if k>=n:
    print(0)
else:
    lst.sort()
    cnt = 0
    for i in range(n-k):
        cnt += lst[i]
    print(cnt)

Submission status: Accepted

Solution code:
import sys
import math
import functools
stdin = sys.stdin
mod = 10**9 + 7

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
sa = lambda h: [list(map(int, stdin.readline().split())) for i in range(h)]

n, k = na()
h = na()
h.sort(reverse=True)
h[:k] = [0]*k
print(sum(h))

Submission status: Accepted

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

l.sort()
s=0
for i in range(len(l)-k):
    s+=l[i]
print(s)

Submission status: Accepted

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

Submission status: Accepted

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

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

for i in range(k):
    if len(h) == 0:
        h.append(0)
        break
    h.pop()

print(sum(h))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,k=[int(x) for x in input().split()]
h=[int(x) for x in input().split()]
if n<=k:
    print(0)
else:
    print(sum(sorted(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(k,n):
    ans += h[i]

print(ans)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

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

H = sorted(H, reverse=True)
for i in range(min(K, N)):
    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)[::-1]

cnt = 0
for i in range(n):
    if i < k:
        pass
    else:
        cnt += H[i]

print(cnt)

Submission status: Accepted

Solution code:
import os,sys
from io import BytesIO, IOBase

def ii(): return int(input())
def si(): return input()
def mi(): return map(int,input().split())
def li(): return list(mi())

mod=1000000007

import math  

for i in range(1):
    n,k=mi()
    h=li()
    h.sort(reverse=True)
    ans=sum(h[k:n])
    print(ans)

Submission status: Accepted

Solution code:


n,k = map(int,input().split())
arr= list(map(int,input().split()))
arr.sort()
arr.reverse()

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

Submission status: Accepted

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

H.sort()

for _ in [0]*min(K,N):
    H.pop()

ans = sum(H)
print(ans)

Submission status: Accepted

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

h.sort()

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

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

Submission status: Accepted

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

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

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

h = sorted(h, reverse=True)
if k >= len(h):
    print(0)
else:
    print(sum(h[k:]))

Submission status: Accepted

Solution code:
import math
import fractions
import bisect
import collections
import itertools
import heapq
import string
import sys
import copy
from collections import deque
sys.setrecursionlimit(10**7)
MOD = 10**9+7
def gcd(a,b):return fractions.gcd(a,b) #最大公約数
def lcm(a,b):return (a*b) // fractions.gcd(a,b) #最小公倍数
def iin(): return int(input()) #整数読み込み
def ifn(): return float(input()) #浮動小数点読み込み
def isn(): return input().split() #文字列読み込み
def imn(): return map(int, input().split()) #整数map取得
def fmn(): return map(float, input().split()) #浮動小数点map取得
def iln(): return list(map(int, input().split())) #整数リスト取得
def iln_s(): return sorted(iln()) # 昇順の整数リスト取得
def iln_r(): return sorted(iln(), reverse=True) # 降順の整数リスト取得
def fln(): return list(map(float, input().split())) # 浮動小数点リスト取得
def join(l, s=''): return s.join(l) #リストを文字列に変換
def perm(l, n): return itertools.permutations(l, n) # 順列取得
def perm_count(n, r): return math.factorial(n) // math.factorial(n-r) # 順列の総数
def comb(l, n): return itertools.combinations(l, n) # 組み合わせ取得
def comb_count(n, r): return math.factorial(n) // (math.factorial(n-r) * math.factorial(r)) #組み合わせの総数
def two_distance(a, b, c, d): return ((c-a)**2 + (d-b)**2)**.5 # 2点間の距離
def m_add(a,b): return (a+b) % MOD

N,K = imn()
H = iln_r()

ans = 0
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 = sorted(list(map(int,input().split())), reverse=True)

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

Submission status: Accepted

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

h_list = sorted(list(map(int, input().split())), reverse=True)
counter = 0
for i in range(1, b+1):
    if i > c:
        counter += h_list[i-1]
print(counter)

Submission status: Accepted

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

Hs.sort(reverse=True)

ans = sum(Hs) - sum(Hs[:K])

print(ans)

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 = [int(i) for i in input().split()]
H = [int(i) for i in input().split()]
H.sort()
index = max(N-K, 0)
H_K = H[:index]
if not H_K:
    ans = 0
else:
    ans = sum(H_K)
print(ans)

Submission status: Accepted

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

    print(ans)

Submission status: Accepted

Solution code:
x, y = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
while y > 0 and len(a) > 0:
  y -= 1
  a.pop()
  
print(sum(a))

Submission status: Accepted

Solution code:
#import sys
MOD = 10 ** 9 + 7
#input = sys.stdin.readline
import math

import itertools

#import bisect

import copy


def sosuhante(n):
    for k in range(2, int(math.sqrt(n))+1):
        if n% k ==0:
            return False
    return True
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def kingaku(a,b,n):
    keta=len(str(n))
    return a*n+b*keta

def my_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return default

#    h,w,a,b = map(int, input().split())
#    c = [[0 for j in range(n)] for i in range(n)]
def main():
    n,k=map(int,input().split())
    h = list(map(int,input().split()))
    h=sorted(h,reverse=True)
    if k > n:
        k=n
    for i in range(k):
        h[i]=0
    print(sum(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)
else:
    H_sort = sorted(H, reverse=True)
    print(sum(H_sort[K:]))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
H = [int(h) for h in 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()
print(sum(H[:max(N-K,0)]))

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,N)):
    H[i]=0
print(sum(H))

Submission status: Accepted

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

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

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

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

Submission status: Accepted

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

H = [int(x) for x in input().split()]

H_sorted = sorted(H, reverse=True)

res = sum(H_sorted[K:])

print(res)

Submission status: Accepted

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

H = sorted(H, key = lambda x: -x)

count = K
ans = 0
for i in H:
    if count > 0:
        count -= 1
        continue
    else:
        ans += i
print(ans)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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=[int(i) for i in input().split(" ")]
H=[int(i) for i in input().split(" ")]

H=sorted(H,reverse=True)
print(sum(H[K:]))

Submission status: Accepted

Solution code:
# coding: utf-8


def solve(*args: str) -> str:
    n, k = map(int, args[0].split())
    H = list(map(int, args[1].split()))
    H.sort(reverse=True)

    return str(sum(H[k:]))


if __name__ == "__main__":
    print(solve(*(open(0).read().splitlines())))

Submission status: Accepted

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

print(sum(hps[k:]))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
a=list(map(int,input().split()))
if k>=n:
    print(0)
    exit()
a=sorted(a,reverse=True)
a=a[k:]

print(sum(a))

Submission status: Accepted

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