Problem:


Score : 300 points

Problem Statement

Fennec is fighting with N monsters.

The health of the i-th monster is H_i.

Fennec can do the following two actions:

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

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

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

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

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

Constraints

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

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

1 \leq H_i \leq 10^9

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N K
H_1 ... H_N

Output

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

Sample Input 1

3 1
4 1 5

Sample Output 1

5

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

Sample Input 2

8 9
7 9 3 2 3 8 4 6

Sample Output 2

0

She can use Special Move on all the monsters.

Sample Input 3

3 0
1000000000 1000000000 1000000000

Sample Output 3

3000000000

Watch out for overflow.



Sample input:
3 1
4 1 5


Sample output:
5

Submission status: Accepted

Solution code:
import bisect
import numpy as np
import math
import itertools
def main():
    N, K = map(int, input().split())
    H = list(map(int, input().split()))

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


    return 0
if __name__ == '__main__':
    main()

Submission status: Accepted

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

for i in range(min(K,N)):
  if K > 0:
    List[i] = 0
    K -= 1

a = sum(List)
print(int(a))

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
H = list(map(int, input().split()))
H.sort(reverse=True)
count1 = 0
count2 = K
for i in range(N):
    if count2 != 0:
        count2 -= 1
    else:
        count1 += H[i]
print(count1)

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()
    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 K>=N:
  print(0)
  exit()
if K==0:
  print(sum(H))
  exit()
  
H.sort()
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);exit()

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

print(ans)

Submission status: Accepted

Solution code:
N, K = list(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:
def resolve():
    import sys
    input = sys.stdin.readline
    
    N, K = map(int, input().split())
    H = list(map(int, input().split()))

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

if __name__ == "__main__":
    resolve()

Submission status: Accepted

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

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

a.sort()
#print(a[:-k])
if k >= len(a):
    print(0)
elif k == 0:
    print(sum(a))
else:
    print(sum(a[:-k]))

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())
hl=list(map(int,input().split()))
ans=0
if n<=k:
    print(0)
else:
    hl.sort(reverse=True)
    temp=hl[(k+1)-1:n]
    for v in temp:
        ans+=v
    print(ans)

Submission status: Accepted

Solution code:
import unittest


class TestC(unittest.TestCase):
    def test_1(self):
        self.assertEqual(think(1, [4, 1, 5]), 5)

    def test_2(self):
        self.assertEqual(think(9, [7, 9, 3, 2, 3, 8, 4, 6]), 0)

    def test_3(self):
        self.assertEqual(think(0, [1000000000, 1000000000, 1000000000]), 3000000000)


def solve():
    k, h = read()
    result = think(k, h)
    write(result)


def read():
    n, k = read_int(2)
    return k, read_int(n)


def read_int(n):
    return read_type(int, n, sep=' ')


def read_float(n):
    return read_type(float, n, sep=' ')


def read_type(t, n, sep):
    return list(map(lambda x: t(x), read_line().split(sep)))[:n]


def read_line(n=0):
    if n == 0:
        return input().rstrip()
    else:
        return input().rstrip()[:n]


def think(k, h):
    if k >= len(h):
        return 0
    h.sort(key=lambda x: -x)
    h[0:k] = [0] * k
    return sum(h)


def write(result):
    print(result)


if __name__ == '__main__':
    # unittest.main()
    solve()

Submission status: Accepted

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

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

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

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

L.sort(reverse=True)

# print(L)

if K >= N:
    print(0)
else:
    for i in range(K):
        L[i] = 0
    ans = sum(L)
    print(ans)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
 
import math
import itertools
import sys
import copy
 
# 入力
#A, B, C, D = map(int, input().split())
#L = list(map(int, input().split()))
#S = list(str(input()))
#N = int(input())
#S = str(input())
N, K = map(int, input().split())
H = list(map(int, input().split()))

H.sort()

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

Submission status: Accepted

Solution code:
import math

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

h.sort()
count = 0

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

print(count)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/python3
# -*- coding: utf-8 -*-
n, k = map(int, input().split())
h = list(map(int, input().split()))
h.sort(reverse=True)
for i in range(0, min(k, n)):
    h[i] = 0
print(sum(h))

Submission status: Accepted

Solution code:
import sys

stdin = sys.stdin

mod = 1000000007
inf = 1 << 60

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()
nas = lambda: stdin.readline().split()

n, k = na()
h = na()
h.sort()
h.reverse()

ans = 0

j = 0
for i in range(n):
    if h[i] > 0:
        if j < k:
            h[i] = 0
            j += 1
        else:
            ans += h[i]
            h[i] = 0

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

sHH = sorted(HH,reverse=True)
if N <= K:
    print(0)
else:
    HHsum = sum(sHH[K:])
    print(HHsum)

Submission status: Accepted

Solution code:
import math

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
from sys import stdin
H,K = [int(x) for x in stdin.readline().rstrip().split()]
H = [int(x) for x in stdin.readline().rstrip().split()]
print(sum(sorted(H)[::-1][K:]))

Submission status: Accepted

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

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

x.sort(reverse=True)

sum = 0

for kk in range(b,a):
    sum += x[kk]


print(sum)

Submission status: Accepted

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

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

K = min(K, N)
print(sum(H[K:]))

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
if n<k:
  k=n
h=list(map(int,input().split()))
h.append(0)
h.sort()
for i in range(k):
  h.pop(-1)
print(sum(h))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
from pprint import pprint

def solve(n, k, h):
    h.sort(reverse=True)
    target = h[k:] if k < n else [0]
    print(sum(target))

if __name__ == '__main__':
    n, k = map(int, sys.stdin.readline().strip().split(" "))
    h = list(map(int,sys.stdin.readline().strip().split(" ")))
    
    solve(n, k, h)

Submission status: Accepted

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

Submission status: Accepted

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

h.sort()

while k > 0 and len(h) > 0:
    h.pop(-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(reverse = True)

del H[0:K]

if H:
    print(sum(H))
else:
    print(0)

Submission status: Accepted

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

Submission status: Accepted

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

h.sort()
res = sum(h[:n-k])
print(res)

Submission status: Accepted

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

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[k:]))

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(reverse=True)
    nh = h[k:]
    print(sum(nh))

Submission status: Accepted

Solution code:
N,M = map(int,input().split())
lis = list(map(int,input().split()))
lis.sort(reverse = True)
su = sum(lis)
if M >= N:
  print(0)
else:
  for i in range(M):
    su -= lis[i]
  print(su)

Submission status: Accepted

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

if (n <= k):
   print(0)
else:
   h.sort(reverse=True)
   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_ = sorted(H)
#print(H_)
ans = 0

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

import itertools as iter
import math
import fractions
from functools import reduce

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

N,K = nums()
H = nums()
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()))
ans=0
H.sort(reverse=True)
for i in range(min(K,len(H))):
  H[i]=0
ans=sum(H)
#print(H)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
import decimal
import queue
import bisect
import heapq
import time
import itertools

mod = int(1e9+7)

class Library():
    @staticmethod
    def Swap(a,b):
        return [b,a]

    @staticmethod
    def myRound(a,dig=0): # 四捨五入
        p = 10 ** dig
        return (a * p * 2 + 1) // 2 / p

    @staticmethod
    def Roundup(a,dig=0): # 切り上げ
        if a < 0:
            return int(a)
        else:
            return int(a + 0.9)

    @staticmethod
    def Gcd(a,b): #最大公約数
        if (a<b):
            a,b = Library.Swap(a,b)
        if (b==0):
            return a
        else:
            return Library.Gcd(b,a%b)

    @staticmethod
    def Lcm(a,b): #最小公倍数
        return a//Library.Gcd(a,b)*b

    @staticmethod
    def Divisors(a): # 約数列挙
        divisors = []
        for i in range(1,int(a**0.5)+1):
            if a%i==0:
                divisors.append(i)
                if i!=a//i:
                    divisors.append(a//i)
        divisors.sort()
        return divisors

class Prime():
    # コンストラクタ
    # エラストテネスの篩
    def __init__(self,num):
        self.num = num
        self.sieve = [0] * (self.num + 1)
        self.sieve[0] = -1
        self.sieve[1] = -1
        for i in range(2,self.num + 1):
            if not self.sieve[i]:
                self.sieve[i] = i
                for j in range(i * i,self.num + 1,i):
                    if self.sieve[j]:
                        self.sieve[j] = i
    
    # 素数判定
    def isPrime(self,num = None):
        if num is None:
            num = self.num
        if self.sieve[num] == num:
            return True
        else:
            return False
    
    # 素数列挙
    def PrimeNum(self,num = None):
        if num is None:
            num = self.num
        prime = []
        for i in range(2,num):
            if self.sieve[i] == i:
                prime.append(i)
        return prime
    
    # 素因数分解
    def PrimeFact(self,num = None):
        if num is None:
            num = self.num
        fact = []
        while self.sieve[num] != num:
            fact.append(self.sieve[num])
            num //= self.sieve[num]
        fact.append(num)
        return fact

def main():
    n,k = map(int,input().split())
    h = list(map(int,input().split()))
    h.sort()
    ans = 0
    for i in range(k):
        if len(h) == 0:
            break
        del h[-1]
    ans += sum(h)
    print(ans)
    return

if __name__=='__main__':
    main()

Submission status: Accepted

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

#整数値入力 1文字の入力
def input_one_number():
    return int(input())

#整数値龍力　複数の入力
def input_multiple_number():
    return map(int, input().split())

#整数値龍力　複数の入力(配列)
def input_multiple_number_as_list():
    return list(map(int, input().split()))

#整数値龍力　複数の入力(配列で1つずつ渡される)
def input_multiple_number_as_list_sep(N):
    ins = []
    for i in range(N):
        ins.append(input())
    return ins

#2次元配列入力
def input_map():
    return [list(map(int,list(input()))) for i in range(h)]

#リスト出力
def print_list(list):
    print(*list)
    return

#2次元配列出力
def print_map(maplist):
    for i in maplist:print(*i, sep='')
    return

#素数生成
def generate_primenums():
    n = 100
    primes = set(range(2, n+1))
    for i in range(2, int(n**0.5+1)):
        primes.difference_update(range(i*2, n+1, i))
    primes=list(primes)
    return primes

def memo():
    a=[0]*5
    b=a  #良くない配列のコピー
    b2=a[:]  #1次元のときはコピーはこれで良い
    a[1]=3
    print('b:{}, b2:{}'.format(b,b2))  #b:[0, 3, 0, 0, 0], b2:[0, 0, 0, 0, 0]
    
    import copy
    a= [[0]*3 for i in range(5)] #2次元配列はこう準備、[[0]*3]*5だとだめ
    b=copy.deepcopy(a)  #2次元配列はこうコピーする
    
    #内包表記奇数のみ
    odd=[i for i in range(100) if i%2==1] #[1, 3, 5, 7, 9, 11, 13, 15, 17, 19]

    #二部探索
    import bisect
    a = [1, 2, 3, 5, 6, 7, 8, 9]
    b=bisect.bisect_left(a, 8)

    #combinations、組み合わせ、順列
    from itertools import permutations, combinations,combinations_with_replacement,product
    a=['a','b','C']
    print(list(permutations(a)))
    print(list(combinations(a,2)))
    print(list(combinations_with_replacement(a,3)))


#階乗
def kaijo(n):
    import math
    return math.factorial(n)

#選び方（コンビネーション nCr）
def num_combination(n,r):
    import math
    return math.factorial(n) // math.factorial(n - r)


#最大公約数、最小公倍数
def calc_gcd(a,b):
    import fractions
    GCD=fractions.gcd(a,b)
    lcm=a*b//gcd
    return gcd,lcm

#複数の最大公約数
def calc_gcd_list(l):
    gcd = l[0]
    for i in range(1, N):
        gcd = fractions.gcd(gcd, l[i])
    return gcd

#各桁の和
def sum_digit(n):
    sum = 0
    while n > 0:
        sum += n%10
        n //= 10
    return sum

givenN,givenK = input_multiple_number()
lst_h = input_multiple_number_as_list()

lst_h.sort()

if givenK != 0:
    lst_h = lst_h[:-givenK]

damage = 0
for a in lst_h:
    damage += a

print(damage)

Submission status: Accepted

Solution code:
n_k = list(map(lambda x: int(x), input().split(" ")))
N = n_k[0]
K = n_k[1]
Hs = list(map(lambda x: int(x), input().split(" ")))
Hs = reversed(sorted(Hs))
result = 0
for h in Hs:
    if K > 0:
        K -= 1
        continue
    result += h

print(result)

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()
    for i 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()))
ans = 0

if n <= k:
    print('0')
else:
    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(x) for x in input().split()]
h.sort(reverse=True)
if k >= n: print(0)
else:
    if k != 0: h = h[k:]
    print(sum(h))

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
def main():
    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:]))


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import math
n,k=map(int,input().split())
arr=list(map(int,input().split()))
arr.sort(reverse=True)
ss=0
for i in range(k,len(arr)):
	ss+=arr[i]
print(ss)

Submission status: Accepted

Solution code:
import heapq

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

hq=[]
for h in hlist:
  heapq.heappush(hq,-h)
  
for i in range(K):
  hmax=heapq.heappop(hq)
  heapq.heappush(hq,0)
  
print(-sum(hq))

Submission status: Accepted

Solution code:
hn=input().split(" ")
N=int(hn[0])
K=int(hn[1])
H=input().split(" ")
H=[int(s) for s in H]
H.sort(reverse=True)
#print(H)
ans=0
for i in range(N):
    if K>0:
        K-=1
    else:
        ans+=H[i]

print(ans)

Submission status: Accepted

Solution code:
# import itertools
# import math


def solve(N, K, H):
    H.sort(reverse=True)
    if N <= K:
        return 0

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


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

# P = []
# S = []
# for i in range(N):
#     pp, ss  = map(int, input().split())
#     P.append(pp)
#     S.append(ss)

print(solve(N, K, H))

Submission status: Accepted

Solution code:
from sys import stdin


def main():
    input = lambda: stdin.readline()[:-1]
    N, K = map(int, input().split())
    H = list(map(int, input().split()))

    H.sort(reverse=1)
    for i in range(min(N, K)):
        H[i] = 0
    print(sum(H))


main()

Submission status: Accepted

Solution code:
a, b = map(int, input().split())
c = list(map(int, input().split()))
c = sorted(c, reverse=True)
d = 1
ans = 0
for i in c:
    if(d<=b):
        d+=1
    else:ans+=i
    #print(i)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import numpy as np

n, k = list(map(int, input().split()))
A = list(map(int, input().split()))
A = np.sort(A)[::-1]

num = float(0)
for i, a in enumerate(A):
    if i >= k:
        num += a

print(int(num))

Submission status: Accepted

Solution code:
N,M = map(int,input().split())
arr = list(map(int,input().split()))
arr = sorted(arr,reverse=True)
if N<=M:
  print(0)
else:
  print(sum(arr[M:]))

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
h = list(map(int, input().split()))
h.sort(reverse=True)
if k != 0:
    del h[0:k]

print(sum(h))

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
def main():
    n,k = map(int,input().split())
    lst = list(map(int,input().split()))
    lst.sort()
    for _ in range(k):
        if len(lst) == 0:
            break
        del lst[-1]
    print(sum(lst))
if __name__ == '__main__':
    main()

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

h = sorted(h, reverse=True)
s = 0

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

Submission status: Accepted

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

Submission status: Accepted

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

if k==0:
    print(sum(li))
    exit()

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

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

print(sum(li))

Submission status: Accepted

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

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

Submission status: Accepted

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


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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from sys import stdin
#n = int(stdin.readline().rstrip())
#l = list(map(int, stdin.readline().rstrip().split()))
n,k = map(int, stdin.readline().rstrip().split())
Hs = list(map(int, stdin.readline().rstrip().split()))
#S = [list(map(int, stdin.readline().rstrip().split())) for _ in range(h)]#hの定義を忘れずに

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

Submission status: Accepted

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

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

h.sort()

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
h = list(map(int, input().split()))
h = sorted(h)
cnt = 0
if n - k >= 1:
    for i in range(n-k):
        cnt += h[i]

print(cnt)

Submission status: Accepted

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

h = sorted(h)
if k == 0:
    print(sum(h))
elif k >= len(h):
    print(0)
else:
    print(sum(h[:-k]))

Submission status: Accepted

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

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
inputs = sys.stdin.readlines()

n, k = map(int, inputs[0].split())
H = list(map(int, inputs[1].split()))

if n-k > 0:
    H.sort()
    print(sum(H[:n-k]))
else:
    print(0)

Submission status: Accepted

Solution code:
#coding:utf-8

def main():
    n, k = map(int, input().split())
    mons = list(map(int, input().split()))
    mons.sort(reverse=True)
    
    print(sum(mons[k:]))
    
main()

Submission status: Accepted

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

lstM.sort(reverse = True)

print(sum(lstM[K:]))

Submission status: Accepted

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

Submission status: Accepted

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

if k >= n:
    result = 0
else:
    H.sort()
    result = sum(H[:n - k])

print(result)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N,K = list(map(int,input().split()))
H = list(map(int,input().split()))
#print(H)
H.sort()
#print(H)
f = True
for i in range(K):
    try:
        H.pop(-1)
    except:
        break
        f = False
if f:
    print(sum(H))
else:
    print(0)

Submission status: Accepted

Solution code:
def main():
	a,b = map(int,input().split())
	l = list(map(int,input().split()))
	
	l.sort()

	for i in range(b):
		if len(l) > 0:
			l.pop(-1)
	print(sum(l))



	

if __name__ == '__main__':
	main()

Submission status: Accepted

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

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

Submission status: Accepted

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

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

lst.sort()
lst2= lst[0:n-k]

print(sum(lst2))

Submission status: Accepted

Solution code:
from bisect import bisect_right, bisect_left
from itertools import groupby, permutations, combinations
from fractions import gcd
import numpy as np
from sys import stdin, stderr


def lcm(x, y):
    return (x * y) // gcd(x, y)


def main():
    N, K = [int(x) for x in input().split()]
    if K >= N:
        return 0
    H = [int(x) for x in input().split()]
    ret = 0
    H.sort()
    for i in range(N - K):
        ret += H[i]
    return ret


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

Submission status: Accepted

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

print sum(H[K:])

Submission status: Accepted

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

higher = sorted(Hn)[::-1]
print(sum(higher[K:]))

Submission status: Accepted

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

Submission status: Accepted

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

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


hh = sorted(h)

for _ in range(k):
    hh.pop()

s = sum(hh)
print(s)

Submission status: Accepted

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

cnt = 0
for i in range(n):
    if cnt < k:
        cnt += 1
        sum_h -= h[i]

print(sum_h)

Submission status: Accepted

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

H.sort(reverse=True)
if N < K:
    K = N
for i in range(K):
    H[i] = 0
#print(H)
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:
    c = N - K
    A = H[:c]
    print(sum(A))

Submission status: Accepted

Solution code:
import sys
def input():
    return sys.stdin.readline()[:-1]

N,K = map(int,input().split(' '))
l = list(map(int, input().split()))
L = sorted(l, reverse=True)
cnt = 0

for i in range(N):
    k = L[i]
    if i<K:
        continue
    cnt += k
print(cnt)

Submission status: Accepted

Solution code:
h,k = map(int, input().split(' '))
h = list(map(int, input().split(' ')))
h = sorted(h
)
for i in range(k):
    if h == []:
        break 
    h.pop()
print(sum(h))