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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

if N <= K:
  X = 0
else:  
  for i in range(N-K):
    X += x[i+K] 
print(X)

Submission status: Accepted

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

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

for i in range(K):
    if len(monster_hp_list) >= 1:
        monster_hp_list.pop()
        K -= 1
    else:
        break
print(sum(monster_hp_list))

Submission status: Accepted

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

Submission status: Accepted

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

h.sort()
s = []
if k == 0:
    s = h
else:
    s = h[:-k]

print(sum(s))

Submission status: Accepted

Solution code:
from heapq import nsmallest
H, K = map(int, input().split())
arr = list(map(int, input().split()))
print(sum(nsmallest(H-K, arr)))

Submission status: Accepted

Solution code:

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

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

h.sort(reverse=True)

print(sum(h[min(n,k):]))

Submission status: Accepted

Solution code:
# abc 153
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)

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

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

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

Submission status: Accepted

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

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

at = 0
for i in intH:
  if K > 0:
    K -= 1
  else:
    at += i

print(at)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
values = input()
Num_monsters, K_skills = map(int, values.split())
values = input()
H_point = list(map(int, values.split()))

if Num_monsters <= K_skills:
    print(0)
else:
    num = Num_monsters - K_skills
    H_point.sort()
    print(sum(H_point[0:num]))

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

Submission status: Accepted

Solution code:
import sys
#import bisect
input = sys.stdin.buffer.readline
#lb = bisect.bisect_left

def main():
	N,K=map(int,input().split())
	vA=list(map(int, input().split()))
	#INF = 1001001001

	vA.sort()
	
	res = sum(vA[:-K]) if K else sum(vA)
	print(res)

main()

Submission status: Accepted

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

H.sort(reverse=True)

S=0
if K<N:
    for i in range(K,N):
        S+=H[i]
    print(S)
else:
    print('0')

Submission status: Accepted

Solution code:
n,k = list(map(int,input().split()))
data = [int(s) for s in input().split()]

data.sort(reverse = True)
ans = 0
if k >= len(data):
  print(0)
  exit()
else:
  for i in range(k,len(data)):
    ans += data[i]
  print(ans)

Submission status: Accepted

Solution code:
S_nk = input().split(" ") #標準入力（N, K）
S_h = input().split(" ") #標準入力（Hi）

N = int(S_nk[0]) #モンスターの種類
K = int(S_nk[1]) #必殺技の制限回数
H = [] #モンスターのヒットポイント
for i in range(N):
  H.append(int(S_h[i]))

#ヒットポイントの大きい順にソート
H.sort(reverse=True)

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

h.sort()
for i in range(k):
    h.pop(-1)
    if len(h) == 0:
        break
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:
    tong = 0
    h.sort()
    for i in range(n-k):
        tong+=h[i]
    print(tong)

Submission status: Accepted

Solution code:
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect


def LI(): return [int(x) for x in sys.stdin.readline().split()]


def I(): return int(sys.stdin.readline())


def LS(): return [list(x) for x in sys.stdin.readline().split()]


def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res


def IR(n):
    return [I() for i in range(n)]


def LIR(n):
    return [LI() for i in range(n)]


def SR(n):
    return [S() for i in range(n)]


def LSR(n):
    return [LS() for i in range(n)]


sys.setrecursionlimit(1000000)
mod = 1000000007


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


# Solve
if __name__ == "__main__":
    solve()

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
def main():
	N,K = map(int,input().split())
	H = [int(h) for h in input().split()]
	H = sorted(H,reverse=True)
	for i in range(min(K,N)):
		H[i] = 0
	print(sum(H))
if __name__ == '__main__':
	main()

Submission status: Accepted

Solution code:
myinput = input()
myinput_H = input()
mylist = list(map(int, myinput.split(" ")))
N = mylist[0]
K = mylist[1]
list_H = list(map(int, myinput_H.split(" ")))
if N - K <= 0:
    print(0)
else:
    x = N - K
    list_H.sort()
    l = list_H[0:x]
    sum = sum(l)
    print(sum)

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

Submission status: Accepted

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

ans = 0
if N > K:
  H.sort()
  ans = sum(H[:N - K])
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)

del h[:k]
print(sum(h))

Submission status: Accepted

Solution code:
N,K = [int(x) for x in input().split()]
n=sorted([int(x) for x in input().split()])
if K>= N: print(0)
else:
  print(sum(n[:N-K]))

Submission status: Accepted

Solution code:
N, K = [int(_) for _ in input().split()]
H = [int(_) for _ 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()
sum = 0
if K<N:
    for i in range(N-K):
        sum += H[i]

print(sum)

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

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from functools import lru_cache
import bisect
import re
import queue


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [input() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [int(input()) for i in range(n)]


class Math():
    @staticmethod
    def gcd(a, b):
        if b == 0:
            return a
        return Math.gcd(b, a % b)

    @staticmethod
    def lcm(a, b):
        return (a * b) // Math.gcd(a, b)

    @staticmethod
    def roundUp(a, b):
        return -(-a // b)

    @staticmethod
    def toUpperMultiple(a, x):
        return Math.roundUp(a, x) * x

    @staticmethod
    def toLowerMultiple(a, x):
        return (a // x) * x

    @staticmethod
    def nearPow2(n):
        if n <= 0:
            return 0
        if n & (n - 1) == 0:
            return n
        ret = 1
        while(n > 0):
            ret <<= 1
            n >>= 1
        return ret

    @staticmethod
    def sign(n):
        if n == 0:
            return 0
        if n < 0:
            return -1
        return 1

    @staticmethod
    def isPrime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3, d + 1, 2):
            if n % i == 0:
                return False
        return True


class PriorityQueue:
    def __init__(self, l=[]):
        self.__q = l
        heapq.heapify(self.__q)
        return

    def push(self, n):
        heapq.heappush(self.__q, n)
        return

    def pop(self):
        return heapq.heappop(self.__q)


MOD = int(1e09) + 7
INF = int(1e15)


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors


def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a


def main():
    # sys.stdin = open("sample.txt")
    N, K = Scanner.map_int()
    H = Scanner.map_int()
    H.sort()
    print(sum(H[:N - min(K, N)]))
    return


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math

temp = input().split(' ')
monter_count = int(temp[0])
kill_count = int(temp[1])
 
temp = input().split(' ')
# 数値の配列に変換
temp = [int(s) for s in temp]
# 体力の多い順にソート
temp.sort(reverse=True)
del(temp[0:kill_count])

print(sum(temp))

Submission status: Accepted

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

print(sum(h[k:]))

Submission status: Accepted

Solution code:
import sys

# sys.stdin = open('input.txt', 'r')

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

health.sort(reverse = True)
ans = 0
for i in range(k, len(health)):
    ans += health[i]
print(ans)

Submission status: Accepted

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

attack = 0
for i, hp in enumerate(reversed(hp_list)):
  if i < k:
    continue
  attack += hp
print(attack)

Submission status: Accepted

Solution code:
def find_minimum_normal_attack(monster_num, special_move_num, monster_healths):
    return sum(sorted(monster_healths, reverse=True)[special_move_num:])


if __name__ == '__main__':
    n, k = map(int, input().split())
    h = list(map(int, input().split()))
    print(find_minimum_normal_attack(n, k, 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:
n,k = map(int,input().split())
h = list(map(int,input().split()))

h = sorted(h)

attack_n = 0

if k >= n:
    attack_n = 0

else:
    for i in h[:n-k]:
        attack_n += i

print(attack_n)

Submission status: Accepted

Solution code:
import heapq

n, k = map(int, input().split())
li = list(map(int, input().split()))
li = list(map(lambda x: x * (-1), li))


def attack():
    if n <= k:
        return (0)
    heapq.heapify(li)
    for i in range(k):
        heapq.heappop(li)
    return - 1 * sum(li)


print(attack())

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
li = list(map(int, input().split()))
arr=sorted(li)
for i in range(k):
  if len(arr)==0:
    break
  arr.pop()
print(sum(arr))

Submission status: Accepted

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

hh = sorted(h)

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

Submission status: Accepted

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

sum = 0
for i in range(N - K):
  sum += Hi[i]

print(sum)

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:
    for i in range(K):
        H[i]=0
    print(sum(H))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

H_list = [i for i in map(int, input().split())]

sorted_H_list = sorted(H_list)

if N <= K:
	print("0")
elif K == 0:
	print(sum(sorted_H_list))
else:
	print(sum(sorted_H_list[:-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:
n,k=map(int,input().split())
l=[int(i) for i in input().split()]
l.sort()
if k>=n:
  print("0")
else:
  sum=0
  for i in range(n-k):
    sum+=l[i]
  print(sum)

Submission status: Accepted

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

H_list.sort(reverse = True)

del H_list[0:K]

print(sum(H_list))

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import collections
n, k = map(int, input().split())
dat = list(map(int, input().split()))
dat.sort(reverse=True)
dat = collections.deque(dat)
res = 0
#print(dat)
for _ in range(min(k, len(dat) )):
    _ = dat.popleft()
    #print(dat)

res += sum(dat)
#print(dat)
print(res)

Submission status: Accepted

Solution code:
n,k = (int(x) for x in input().split())
h_lst = [int(x) for x in input().split()]
h_lst.sort()
if k != 0:
    del h_lst[(-1)*k:]
print(sum(h_lst))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
x, y = (int(x) for x in input().split())
a = (int(x) for x in input().split())

print(sum(sorted(a,reverse=True)[y:]))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a,c=map(int,input().split())
b=list(map(int,input().split()))
b.sort(reverse=True)
if a>c:
    print(sum(int(i) for i in b[c:]))
else:
    print(0)

Submission status: Accepted

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

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

Submission status: Accepted

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

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

# K は必殺技
# 最小の攻撃数は？ 1減らし

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

print(rh)

Submission status: Accepted

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

hissatsu = n-k

if hissatsu <= 0:
  print(0)
else:
  monsters.sort(reverse=True)
  print(sum(monsters[-hissatsu:]))

Submission status: Accepted

Solution code:
H,K = map(int,input().split())
Hi = sorted(map(int,input().split()))
z = len(Hi) - K
if z<0:
  z = 0
hi = Hi[:z]
print(sum(hi))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
H = sorted(map(int, input().split()))
total = 0
if N > K:
  for i in range(0, N-K):
    total += H[i]
print(total)

Submission status: Accepted

Solution code:
a, b = input().split()
c = list(map(int, input().split()))
d = int(b)
e = sorted(c,reverse=True)
ans = 0

if d >= len(e):
  print("0")
else:
  if d == 0:
    for j in e:
      ans += j
    print(str(ans))
  else:
    for i in range(d):
      e[i] = 0
    for j in e:
      ans += j
    print(str(ans))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
N,K = [int(i) for i in input().split()]
H = [int(i) for i in input().split()]
H.sort()
ans = 0
for i in range(N - K) :
    ans += H[i]
print(ans)

Submission status: Accepted

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

if b >= sum(attack_list): print(0)

attack_list.sort()
if(b == 0):
    print(sum(attack_list))
else:
    print(sum(attack_list[:-b]))

Submission status: Accepted

Solution code:
N,K = map(int, input().split())
#print(N,K)
H = list(map(int, input().split()))
#H = input().split()
#print(H)
if N<=K:
  print(0)
else:
  # Hの中身を入れ替えて大きいものから順に必殺技で倒す
  # つまり、配列をカットする
  # 配列の残りの和が倒すのに必要な数
  H.sort(reverse=True)
  newH = H[K:]
  sumH = sum(newH)
  print(sumH)

Submission status: Accepted

Solution code:
numbers = input().split(" ")
enemy_num = int(numbers[0])
kill_num = int(numbers[1])

enemy_hp_list = input().split(" ")
for i, hp in enumerate(enemy_hp_list):
  enemy_hp_list[i] = int(hp)

enemy_hp_list.sort(reverse=True)
target = enemy_hp_list[kill_num:]
count = 0
for i in target:
  count += i
print(count)

Submission status: Accepted

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


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

hps.sort(reverse=True)

if len(hps) < K:
  hps = [0]
else:
  hps = hps[K:]

sum_hps = sum(hps)
print(sum_hps)

Submission status: Accepted

Solution code:
n,k=(int(i) for i in input().split())
h=[]
for i in input().split():
  h.append(int(i))
h.sort()
if k!=0:
	for i in range(min(n,k)):
 	  h.pop(-1)
print(sum(h))

Submission status: Accepted

Solution code:
n,k=(int(i) for i in input().split())
h=[]
for i in input().split():
  h.append(int(i))
h.sort()
if k!=0:
	for i in range(min(n,k)):
 	  h.pop(-1)
print(sum(h))

Submission status: Accepted

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

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

Submission status: Accepted

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

data.sort()

for _ in range(k):
  if data.__len__() > 0:
    data.pop()
  else:
    break

print(sum(data))

Submission status: Accepted

Solution code:

def sRaw():
    return input().rstrip("\r")


def iRaw():
    return int(input())


def ssRaw():
    return input().split()


def isRaw():
    return list(map(int, ssRaw()))

INF = 1 << 29

DIV = (10**9) + 7

def mod_inv_prime(a, mod=DIV):
    return pow(a, mod-2, mod)

def mod_inv(a, b):
    r = a
    w = b
    u = 1
    v = 0
    while w != 0:
        t = r//w
        r -= t*w
        r, w = w, r
        u -= t*v
        u, v = v, u
    return (u % b+b) % b


def CONV_TBL(max,mod=DIV):
    fac,finv,inv = [0]*max, [0]*max, [0]*max
    fac[0]=fac[1]=1
    finv[0]=finv[1]=1
    inv[1]=1
    for i in range(2,max):
        fac[i] = fac[i-1]*i % mod
        inv[i] = mod -inv[mod%i] * (mod//i)%mod
        finv[i] = finv[i-1]*inv[i]%mod
    class CONV:
        def __init__(self):
            pass
        def ncr(self,n,k):
            if(n<k):
                return 0
            if(n<0 or k<0 ):
                return 0
            return fac[n]*(finv[k]*finv[n-k]%mod)%mod
    return CONV()



def main():
    N,K = isRaw()
    Hs = isRaw()
    Hs.sort()
    ans = 0
    for eidx in range(0,N-K):
        ans+=Hs[eidx]
    return ans


if __name__ == "__main__":
    print(main())

Submission status: Accepted

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

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

if N <= K:
    print('0')
else:
    print(sum(list(sorted(H, reverse=True))[K:N]))

Submission status: Accepted

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

Submission status: Accepted

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

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
mod2 = 998244353
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 list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    n,m = LI()
    a = sorted(LI())
    if n <= m:
        return 0

    return sum(a[:n-m])


print(main())

Submission status: Accepted

Solution code:
# ABC153
# C

N, K = [int(s) for s in input().split()]
H_list = [int(s) for s in input().split()]
H_list.sort(reverse=True)

if N < K:
    K = N

for i in range(int(K)):
    H_list[i] = 0

print(sum(H_list))

Submission status: Accepted

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

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

if n<=k:
    print(0)
else:
    h = sorted(h, reverse=True)
    ans = sum(h)
    for i in range(k):
        ans -= h[i]
    print(ans)

Submission status: Accepted

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

sorted_H = sorted(H)
sum = 0

for i in range(N-K):
    sum += sorted_H[i]

print(sum)

Submission status: Accepted

Solution code:
N,K=[int(thing) for thing in input().split(" ")]
H_list=[int(thing) for thing in input().split(" ")]
H_list=sorted(H_list,reverse=True)
fuckable=sum(H_list[0:K])
health_sum=sum(H_list)
need_attack=health_sum-fuckable
print(need_attack)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a,b = map(int,input().split(" "))
ar = list(map(int,input().split(" ")))
count = 0
if a <= b:
    print(0)
else:
    ar.sort()
    for i in range(a-b):
        count += ar[i]
    print(count)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n, k = map(int, input().split(" "))
l = list(map(int, input().split(" ")))
l.sort(reverse=True)
del l[0:k]
res = sum(l)
print(res)

Submission status: Accepted

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

Submission status: Accepted

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

e.sort()
if k < len(e):
    print(sum(e[0:len(e)-k]))
else:
    print(0)

Submission status: Accepted

Solution code:
import heapq

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

heapq.heapify(h)
if n-k >= 0:
    print(sum(heapq.nsmallest(n-k, h)))
else:
    print(0)

Submission status: Accepted

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

atackTimes = 0

monsterList.sort()
if K != 0:
    for hp in monsterList[:-K]:
        atackTimes += hp
else:
    for hp in monsterList:
        atackTimes += hp

print(atackTimes)

Submission status: Accepted

Solution code:
# coding: utf-8
import sys
import math

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

l.sort(reverse=True)
if len(l)-K<=0:
  print(0)
else:  
  cnt=l[-(len(l)-K):]
  print(sum(cnt))

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

Submission status: Accepted

Solution code:
def wczytaj_liste():
    ciag = input()
    rozdzielona_lista = ciag.split()
    odp = []
    for wyraz in rozdzielona_lista:
        liczba = int(wyraz)
        odp.append(liczba)
    return odp

def C():
    N, K = wczytaj_liste()
    zycie_monsterow = wczytaj_liste()
    zycie_monsterow.sort()
    ilosc_monsterow = N-K
    if ilosc_monsterow <= 0:
        print(0)
    else:
        print(sum(zycie_monsterow[:ilosc_monsterow]))

C()

Submission status: Accepted

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

if N <= K:
    attack = 0
else:
    sorted_H = sorted(H, reverse=True)
    attack = sum(sorted_H[K:])
print(attack)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#n = int(input())
#s = input()
n,m = map(int,input().split())
da = list(map(int,input().split()))

da = sorted(da)

ans = 0
for i in range(n-m):
    ans += da[i]
print(ans)

Submission status: Accepted

Solution code:
n, k = (int(x) for x in input().split())
h = (int(x) for x in input().split())
h = sorted(h, reverse=True)
cnt = 0
res = 0
for i in h:
    if cnt >= k:
        res += i
    cnt += 1
print(res)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S1 = list(map(int, input().split()))
S2 = list(map(int, input().split()))

H = S1[0]
K = S1[1]
S2.sort()

if K == 0:
    print(sum(S2))
else:
    print(sum(S2[:-K]))