Problem:


Score : 300 points

Problem Statement

Fennec is fighting with N monsters.

The health of the i-th monster is H_i.

Fennec can do the following two actions:

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

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

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

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

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

Constraints

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

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

1 \leq H_i \leq 10^9

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N K
H_1 ... H_N

Output

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

Sample Input 1

3 1
4 1 5

Sample Output 1

5

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

Sample Input 2

8 9
7 9 3 2 3 8 4 6

Sample Output 2

0

She can use Special Move on all the monsters.

Sample Input 3

3 0
1000000000 1000000000 1000000000

Sample Output 3

3000000000

Watch out for overflow.



Sample input:
3 1
4 1 5


Sample output:
5

Submission status: Accepted

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

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

if K >= len(H):
    ans = 0
else:
    H.sort()
    for i in range(0, len(H)-K):
        ans += H[i]

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

main()

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
from __future__ import print_function

import sys
input = sys.stdin.readline


def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
    return


# import re
# import array
# import copy
# import functools
# import operator

# import math
# import string
import fractions
# from fractions import Fraction
from fractions import gcd

# import collections
# import itertools
# import bisect

# import heapq
# from heapq import heappush
# from heapq import heappop
# from heapq import heappushpop
# from heapq import heapify
# from heapq import heapreplace
# from queue import PriorityQueue as pq
from queue import Queue

# from itertools import accumulate

# from collections import deque
# from collections import Counter

from operator import mul
from functools import reduce

# def lcm(n,m):
#     return int(n*m/gcd(n,m))


def coprimize(p, q):
    common = fractions.gcd(p, q)
    return (p // common, q // common)


def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom


# import random
# import time

n, k = map(int, input().strip().split())
h = list(map(int, input().strip().split()))
h.sort()
if k > n:
    print(0)
    sys.exit()
else:
    for i in range(k):
        h.pop()
        # eprint(h)
print(sum(h))

Submission status: Accepted

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

ans = 0
if K>=N:
  print(ans)
else:
  H.sort(reverse=True)
  for i in range(K, N):
    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=sorted(h)

if len(h) <= k:
    print(0)
else:
    buf=h[0:len(h)-k]
    """for i in range(k):
       del h[-1]"""
    print(sum(buf))

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

list_score.sort()

if h >= len(list_score):
    h = len(list_score)

for i in range(h):
    list_score.pop(-1)

ans = sum(list_score)

print(ans)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

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

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

h.sort()

if n - k <= 0:
    print("0")
else:
    rh = h[:n - k]
    ans = 0
    for i in rh:
        ans += i
    
    print(ans)

Submission status: Accepted

Solution code:

from heapq import heappop, heapify, heappush
N, K = map(int, input().split())
H = list(map(int, input().split()))

heap = []
for h in H:
  heappush(heap, -h)

cnt = 0
while heap:
  if K > 0:
    heappop(heap)
    K -= 1
    continue

  h = -heappop(heap)
  if h > 0:
    cnt += h

print(cnt)

Submission status: Accepted

Solution code:
import collections
import itertools as it
import math
import numpy as np

# A = input()
# A = int(input())
# A = map(int, input().split())
# A = list(map(int, input().split()))
# A = [int(input()) for i in range(N)]
#
# c = collections.Counter()
N, K = map(int, input().split())
H = list(map(int, input().split()))

H.sort()

rest = sum(H[::-1][K:])

print(rest)

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]


print(sum(h))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, K = input().split(" ")
Hs = input().split(" ")

N, K = int(N), int(K)
Hs = [int(H) for H in Hs]
if N <= K: 
    print(0)
else:
    sorted_Hs = sorted(Hs) # 体力の低い順に並べ替え
    if K == 0: 
        attack_Hs_count = sum(sorted_Hs)
    else: 
        attack_Hs_count = sum(sorted_Hs[:-K])
    print(attack_Hs_count)

Submission status: Accepted

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

Submission status: Accepted

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

if len(h) < k:
    print('0')
else:
    for _ in range(k):
        h.pop()

    print(sum(h))

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
H = list(map(int, input().split()))
H = list(reversed(sorted(H)))
if k >= n:
    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()

for i in range(k):
    if(len(h) > 0):
        h.pop()
    else:
        break

print(sum(h))

Submission status: Accepted

Solution code:
import math
P = [int(p) for p in input().split()]
N = P[0]
K = P[1]

H = [int(a) for a in input().split()]
H.sort()
if(K>0):
  A = H[:-K]
else:
  A = H
print(sum(A))

Submission status: Accepted

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

hit_points = list(map(int, input().split()))
hit_points.sort()

for _ in range(K):
    if hit_points == []:
        break
    hit_points.pop()

print(sum(hit_points))

Submission status: Accepted

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

for i in range(K):
  if not not H:
    H.pop(-1)
print(sum(H))

Submission status: Accepted

Solution code:
a = input().split(" ")
a =[int(i) for i in a]
N = a[0] #Nはモンスターの数
K = a[1] #Kは必殺技を使える回数

kai = 0
H = input().split(" ")
H =[int(i) for i in H]
H.sort(reverse=True)

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

Submission status: Accepted

Solution code:
n,k=map(int, input().split())
h=list(map(int, input().split()))
if n<=k:
    print(0)
else:
    h_mintomax=sorted(h)
    for i in range(k):
        h_mintomax.pop()
    print(sum(h_mintomax))

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:
R = lambda: map(int, input().split())
n, k = R()
print(sum(sorted(R())[:n - k]) if k < n else 0)

Submission status: Accepted

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

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

a_list.sort(reverse=True)

sum_d = 0

for i, x in enumerate(a_list):
    if(b != 0):
        b -= 1 
    else:
        sum_d += x

print(sum_d)

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
monster_num,k = map(int,input().split(" "))
hp = list(map(int,input().split(" ")))
hp = sorted(hp, reverse = True)

total = 0
for i in hp:
    total += i
    
s = 0
for i in range(k):
    if s <= len(hp) - 1:
        total -= hp[s]
        s += 1

print(total)

Submission status: Accepted

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

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

Submission status: Accepted

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

# 昇順にソート
H.sort()

if K >= len(H):
    print("0")
else:
    for i in  range(K):
        H.pop()
    print(sum(H))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

#print N, K, H
H.sort()
#print H

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

print sum

Submission status: Accepted

Solution code:
n,k = input().split()
N = int(n)
K = int(k)
H = [int(x) for x in input().split()]

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

print(total)

Submission status: Accepted

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

Submission status: Accepted

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

if n <= k:
    print(0)
elif k == 0:
    print(sum(h))
elif n > k:
    h.sort(reverse=True)
    t = h[k:]
    print(sum(t))

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

h.sort(reverse=True)

ans = 0
if k >= len(h):
  print(0)
  sys.exit()

for i in h:
  if k > 0:
    k -= 1
    continue
  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)
for i in range(k):
  if i >= n:
    break
  h[i] = 0
print(sum(h))

Submission status: Accepted

Solution code:
import numpy as np

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

h = np.array(sorted(h))

if(k > 0):h = h[:-k]


print(sum(h))

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
L = list(sorted(map(int, input().split())))
out = 0
if k >= n:
  print(0)
elif k == 0:
  for i in L:
    out += i
  print(out)
else:
  for i in L[0:-k]:
    out += i
  print(out)

Submission status: Accepted

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


def solve(N: int, K: int, H: "List[int]"):
    H.sort()
    print(0 if N<=K else sum(H[:N-K]))
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    H = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, K, H)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N, K = [int(i) for i in input().split()]
mon_list = [int(i) for i in input().split()]
mon_list = sorted(mon_list, reverse=True)
if N <= K:
    output = 0
else:
    if K != 0:
        output = sum(mon_list[K:])
    else:
        output = sum(mon_list)
print(output)

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()
    for _ in range(K):
        H.pop()

    kaisuu = 0
    for i in range(len(H)):
        kaisuu += H[i]

    print(kaisuu)

Submission status: Accepted

Solution code:
import sys,collections,math,random,fractions,bisect;sys.setrecursionlimit(10**7)
sr = sys.stdin.readline; P = print; P2 = lambda x: print(*x, sep="\n")
def I(i=0): t = [int(x)-i for x in sr().split()];return t 
def S(): t = sr().split(); return t if len(t) > 1 else t[0]
L1,L2,L3,L4, = [],[],[],[]

N,K = I()
A = I()
if K>N:
    K=N
if N == K:
    print(0)
else:
    print(sum(sorted(A)[:N-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:
    cnt=0
    for i in range(k,n):
        cnt+=h[i]
    print(cnt)

Submission status: Accepted

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

list = list[k:]

if list == []:
  print(0)
else:
  print(sum(list))

Submission status: Accepted

Solution code:
N , K = map ( int , input().strip().split(" ") ) ;
L = list ( map ( int , input().strip().split(" ") ) ) ;
L.sort() ;

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math

N,MP=map(int, input().split())
HP=list(map(int, input().split()))
HP.sort()
HP.reverse()
if MP==0:
    print(sum(HP))
elif N<=MP:
    print(0)
else:
    del HP[0:MP]
    print(sum(HP))

Submission status: Accepted

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

h.sort()
c = list(reversed(h))

ans = 0
if n > k:
    ans = sum(c[k:])
print(ans)

Submission status: Accepted

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

H.sort(reverse=False)
if k >= len(H):
    print("0")
    exit()
for i in range(k):
    H.pop(-1)
print(sum(H))

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import math


def inputIntList():
  return [int(s) for s in input().split()]


def inputInt():
  return int(input())


def main():
  N, K = inputIntList()
  H = inputIntList()
  H = sorted(H, reverse=True)[K:]
  ans = sum(H)
  return ans


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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sun Jan 26 21:09:11 2020

@author: H_Hoshigi
"""

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

H_list = list(map(int, input().split()))
H_list.sort(reverse=True)

answer = None
if K >= N:
    answer = 0
else:
    answer = sum(H_list[K:])

print(answer)

Submission status: Accepted

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

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

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

h.sort(reverse=True)

for i in range(k,n):

    attack += h[i]
print(attack)

Submission status: Accepted

Solution code:
import numpy as np

NK=np.array(input().split(" "),dtype=np.int64)
N=NK[0]
K=NK[1]

H=np.array(input().split(" "),dtype=np.int64)

sort_H=np.sort(H)[::-1]

remain_H=np.sum(sort_H[K::])

print(remain_H)

Submission status: Accepted

Solution code:
import sys

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

if k>=n:
  print(int(0))
  sys.exit()

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

Submission status: Accepted

Solution code:
import sys

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

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

a = sorted(monster, reverse=True)

if H <= k:
  print(0)
  sys.exit()

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

print(sum(a))

Submission status: Accepted

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

print(sum(Hs[K:]))

Submission status: Accepted

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

h_sort = sorted(h, reverse = True)
n = int(sum(h_sort[k : n+1]))

print(n)

Submission status: Accepted

Solution code:
# /usr/bin/python3
# -*- coding: utf-8 -*-
from queue import Queue
from queue import LifoQueue as Stack
from math import sqrt
from fractions import gcd
from itertools import permutations, combinations

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

def intinput():
    return int(input())

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

def lineinputs(func=intinput):
    datas = []
    while True:
        try:
            datas.append(func())
        except EOFError:
            break
    return datas



N, K = mulinputs()
Hs = list(mulinputs())


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

# 出力
print(sum(Hs))

Submission status: Accepted

Solution code:
# スペース区切りの整数入力
h,k = map(int, input().split())
# スペース区切りの整数をリストに入力
h = [int(x) for x in input().split()]
hh = 0
for i in sorted(h,reverse=True)[k:]:
    hh = hh + i

print(hh)

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
Hs = sorted(list(map(int, input().split())))
if K >= N:
  print("0")
else:
  while K > 0:
    Hs.pop()
    K -= 1
  print(sum(Hs))

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
H = list(map(int, input().split())) # N匹のモンスターの体力
ans = 0
tot = 0

if N <= K:
    tot = 0
else:
    H.sort(reverse = False)
    for i in range(N - K):
        tot += H[i]
        
print(tot)

Submission status: Accepted

Solution code:
A = list(map(int, input().split()))
B = list(map(int, input().split()))
B = sorted(B)
i = 0
for k in range(A[0]-A[1]):
  i = i + B[k]
print(i)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N, K = map(int,input().split())
monsters = [int(i) for i in input().split()]
monsters.sort(reverse=True)
deleted_monsters = []
for i in range(N):
    if i < K:
        deleted_monsters.append(0)
    else:
        deleted_monsters.append(monsters[i])
print(sum(deleted_monsters))

Submission status: Accepted

Solution code:
# h,n,*a=map(int,open(0).read().split())

# h = int(input())
n, k = [int(x) for x in input().split()]
# k = int(input())

# ヨコ
h = [int(x) for x in input().split()]

# タテ
# m = [int(input()) for _ in range(N)]
if n <= k:
  print(0)
  exit()

h = sorted(h)

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

Submission status: Accepted

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

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

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

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

#K = 1
#N = 3
#An = [4,1,5]

import numpy as np

if N<=K:
    print(0)
else:
    remain = N - K
    An.sort()
    print(np.sum(An[:remain]))

Submission status: Accepted

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

H_sorted = sorted(H, reverse=True)

if K <= N:
    del H_sorted[:K]
    print(sum(H_sorted))
else:
    print(0)

Submission status: Accepted

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

count = 0
for i in range(len(H) - K):
    count += H[i]

print(count)

Submission status: Accepted

Solution code:
N, K = [int(s) for s in input().split()]
H = [int(s) for s in input().split()]
if N <= K:
  print(0)
else:
  H.sort()
  total = sum(H[0:N-K])
  print(total)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#solve
def solve():
    n, k = LI()
    h = LI()
    h.sort(reverse=True)
    print(sum(h[k:]))
    return


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

Submission status: Accepted

Solution code:
N,K = map(int,input().split())
List=list(map(int,input().split()))
List.sort(reverse=True)
if len(List) <= K:
  print(0)
else:
  print(sum(List[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 = list(map(int, input().split()))

h.sort()
for _ in range(k):
    h.pop()
    if not h:
        break
ans = sum(h)
print(ans)

Submission status: Accepted

Solution code:
s = input().rstrip().split(' ')
N = int(s[0])
K= int(s[1])
Hs = list(map(int, input().rstrip().split(' ')))

Hs = sorted(Hs, reverse=True)
count = 0

for h in Hs:
    if K == 0:
        count = count + h
    else:
        K = K - 1
print(count)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
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 = list(map(int,input().split()))
h = sorted(h,reverse=True)
if k>= len(h):
  print(0)
else:
  h = h[k:]
  print(sum(h))

Submission status: Accepted

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

import numpy as np

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

Hn = np.array(input().split(" "), dtype=np.int)

Hn = np.sort(Hn)[::-1]

if N >= K:
    out = np.sum(Hn[K:])
else:
    out = 0

print(out)

Submission status: Accepted

Solution code:
[N,K] = [int(s) for s in input().rstrip().split(' ')] #Nモンスター数,K必殺技回数
H = [int(s) for s in input().rstrip().split(' ')] #各モンスターの体力
S = 0 #通常攻撃の回数
if K >= N:
    print(0)
else:
    H_0 = sorted(H, reverse = True)
    h_0 = H_0[K:]
    print(sum(h_0))

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
line = input().rstrip().split(' ')
n = int(line[0])
k = int(line[1])

line = input().rstrip().split(' ')
h = [0] * n
for i in range(n):
    h[i] = int(line[i])

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

print(ans)

Submission status: Accepted

Solution code:
import numpy as np
N,K = list(map(int,input().split()))
H = list(map(int,input().split()))
H.sort()

if N <= K:
  print(0)
else:
  N = N - K
  H = H[:N]
  s = np.array(H).sum()
  print(int(s))

Submission status: Accepted

Solution code:
def main():
    N, K = map(int, input().split())
    H = list(map(int, input().split()))
    H2 = sorted(H)
    a = N-K
    if N-K >= 0:
        print(sum(H2[0:N-K]))
    elif N-K < 0:
        print(0)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

n = a[0]
k = a[1]

b.sort()

total = 0
for i in range(n - k - 1, -1, -1):
  total += b[i]

print(total)

Submission status: Accepted

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

Submission status: Accepted

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

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

if n < k:
    k = n

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

ans = sum(h)

print(ans)

Submission status: Accepted

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

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

h = sorted(map(int, input().split()))
if K > 0:
    h = h[:-K]
print(sum(h))

Submission status: Accepted

Solution code:
nk = input().split()
h_tmp  = input().split()
n=int(nk[0])
k=int(nk[1])
h = [0]*n
for i in range(n):
 h[i] = int(h_tmp[i])
h.sort(reverse=True)
print(sum(h[k:n]))

Submission status: Accepted

Solution code:
N,K=map(int, input().split())
H=list(map(int, input().split()))
for i in range(N):
    H[i]=-H[i]
import heapq as hq
hq.heapify(H)
if K>N:
    K=len(H)
for i in range(K):
    a=hq.heappop(H)
#print(H)
total=0
for i in range(len(H)):
    total-=H[i]
print(total)
#total+=K
#print(total)

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

Submission status: Accepted

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

answer = 0
H.sort()
ll = len(H)
k = ll - K
if k < 0:
    answer = 0
else:
    answer = sum(H[:k])

print(answer)

Submission status: Accepted

Solution code:
N,K=map(int, input().split())
H=list(map(int,input().split()))
count=0
H.sort(reverse=True)
#print(H)
i=K
#print(i)
while i<len(H):
    count=count+H[i]
    i=i+1
    #print(i)

print(count)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sun Jan 19 20:52:57 2020

@author: over-
"""

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
# coding: utf-8
n,k = map(int, input().split())
H = sorted(map(int, input().split()))

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

Submission status: Accepted

Solution code:
import numpy as np

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

Hs = np.sort(H)[::-1]

times = 0
for i in range(K,len(Hs)):
    times += Hs[i]

print(times)

Submission status: Accepted

Solution code:
N,K = map(int,input().split())
H = list(map(int,input().split()))
H.sort()
count= 0
if len(H) <= K:
    print(0)
else:
    for i in range(len(H)-K):
        count += H[i]
    print(count)