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 = input().split()
H = input().split()
if int(K) >= int(N):
    print(0)
else:
    attack = 0
    H = list(map(int, H))
    H.sort(reverse = True)
    del H[0:int(K)]
    for x in H:
        attack += x
    print(attack)

Submission status: Accepted

Solution code:
import sys
n, k = map(int, sys.stdin.readline().split())
h = []
h.extend(sorted(map(int, sys.stdin.readline().split())))

if k > 0:
  del h[-k:]
print(sum(h))

Submission status: Accepted

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

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

ans = 0

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

print(ans)

Submission status: Accepted

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

N = int(N)
K = int(K)

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

Submission status: Accepted

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

def main():
    N, K = map(int, input().split())
    H = sorted([int(i) for i in input().split()], reverse=True)
    if K >= len(H):
        print(0)
    else:
        print(sum(H[K:]))


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import math
import string
import itertools
import fractions
import heapq
import collections
import re
import array
import bisect
import sys
import random
import time
inf = 10**9


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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

atk=sum(H)
print(atk)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import heapq

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

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

print(sum(heapq.nsmallest(n-k,h)))

Submission status: Accepted

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

H_list.sort(reverse=True)

ans = 0

for i in range(N):
  if K<=0:
    ans += H_list[i]
  else:
    K -= 1
    
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
monster_num, special_num = map(int ,input().split())
monster_list = list(map(int, input().split()))
 
monster_list = sorted(monster_list)[::-1]
 
monster_list = monster_list[special_num:]
  
print(sum(monster_list))

Submission status: Accepted

Solution code:
en_num, sp_atk_num = map(int, input().split())
en_list = sorted(list(map(int, input().split())), reverse=True)[sp_atk_num:]

if len(en_list) == 0:
	print(0)
else:
	res = 0
	for e in en_list:
		res += e
	print(res)

Submission status: Accepted

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

if N < K:
  print(0)
else:
  H = list(map(int, input().split()))
  H.sort()
  for _ in range(K):
    del H[-1]
  print(sum(H))

Submission status: Accepted

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

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
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 main():
    N, K = LI()
    H = LI()
    H = sorted(H)
    while K > 0 and len(H) > 0:
        H.pop()
        K -= 1
    print(sum(H))
main()

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
h,n = map(int,input().split())
g = input().split()
G = sorted([int(j) for j in g])
if n != 0:
    del G[-n::]
print(sum(G))

Submission status: Accepted

Solution code:
import sys
import socket

hostname = socket.gethostname()

if hostname == 'F451C':
    sys.stdin = open('c1.in')


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


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


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


def read_str():
    return input()


def main():
    N, K = read_int_list()
    H = read_int_list()
    res = 0
    if K < N:
      H0 = sorted(H, reverse=True)
      del H0[0:K]
      res = sum(H0)
    print(res)

main()

Submission status: Accepted

Solution code:
import sys
import socket

hostname = socket.gethostname()

if hostname == 'F451C':
    sys.stdin = open('c1.in')


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


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


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


def read_str():
    return input()


def main():
    N, K = read_int_list()
    H = read_int_list()
    res = 0
    if K < N:
      H = sorted(H, reverse=True)
      del H[0:K]
      res = sum(H)
    print(res)

main()

Submission status: Accepted

Solution code:
import sys
import socket

hostname = socket.gethostname()

if hostname == 'F451C':
    sys.stdin = open('c1.in')


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


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


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


def read_str():
    return input()


def main():
    N, K = read_int_list()
    H = read_int_list()
    res = 0
    if K < N:
      H.sort(reverse=True)
      del H[0:K]
      res = sum(H)
    print(res)

main()

Submission status: Accepted

Solution code:
def main():
    n, k = [int(i) for i in input().split()]
    num = [int(i) for  i in input().split()]
    if k >= n:
        return 0
    else:
        num = sorted(num)
        return sum(num[0:n-k])
print(main())

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
line=input()
data=input()
line=line.split()
data=data.split()
num=0
if int(line[0])<=int(line[1]):
    print(0)
else:
    data=[int(s) for s in data]
    data_sorted=data.sort()
    for i in range(len(data)-int(line[1])):
        num+=data[i]
    print(num)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, K, *H = map(int, open(0).read().split())
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()
ans=sum(h[:max(n-k,0)])
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

ans = 0
Hn.sort()
K = min(H, K)
print(sum(Hn[:H-K]))

Submission status: Accepted

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

H = sorted(H, reverse=True)

del H[:K]
if H:
  total = sum(H)
else:
  total = 0

print(total)

Submission status: Accepted

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

Submission status: Accepted

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

    H.sort()

    if N <= K:
        print(0)
        return

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

    print(point)


solve()

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n, k = list(map(int, input().split()))
h = list(map(int, input().split()))
h.sort()
ans = 0
if n > k:
    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)

ans = 0
for i in range(N):
    if i<K:
        pass
    else:
        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)
attack = 0
i=0
for h in H:
    if i >= K:
        attack += h
    i += 1
print(attack)

Submission status: Accepted

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

if k >= n:
    print(0)
else:
    h_des = sorted(h_list,reverse=True)
    print(sum(h_des[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:
  for i in range(K):
    H[i] = 0
else:
  for i in range(N):
    H[i] = 0
print(sum(H))

Submission status: Accepted

Solution code:
n, k = map(int, input().split()) ###n:モンスターの数，k:必殺技の回数
h=sorted(list(map(int,input().split()))) ###h:モンスターの体力

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

Submission status: Accepted

Solution code:
import numpy as np
n, k = map(int, input().split())
a_list = np.array(list(map(int, input().split())))
a_list_sorted = np.sort(a_list)[::-1]
print(a_list_sorted[k:].sum())

Submission status: Accepted

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

Submission status: Accepted

Solution code:
tmp = input().split(" ")
N = int(tmp[0])
K = int(tmp[1])
tmp = input().split(" ")
A = [int(i) for i in tmp]
A.sort(reverse = True)
print(sum(A[K:]))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
if __name__ == '__main__':
    n, k = list(map(int, input().split()))
    h = list(map(int, input().split()))
    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 = map(int, input().split())
print("0" if k >= n else sum(sorted(h)[:n-k]))

Submission status: Accepted

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

h_i = input().split()
h_i = [int(N) for N in h_i]
h_i.sort()
if N < K:
    print("0")
else :
    newh_i = h_i[0:N-K]
    print(sum(newh_i))

Submission status: Accepted

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

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

Submission status: Accepted

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

n = int(n)
k = int(k)

if n <= k:
	print("0")
else:
	a.sort(reverse=True)
	a = a[k: ]
	s=sum(a)
	print(s)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
  n, k = input().split(" ")
  enemies = list(map(int, input().split(" ")))
  n, k = int(n), int(k)
  count = 0

  if n > k:
    enemies.sort()
    count = sum(enemies[:n-k])
  print(count)

if __name__ == "__main__":
   main()

Submission status: Accepted

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

for i in range(N):
    if i < K:
        pass
    else:
        sum += H[i]

print(sum)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

H.sort(reverse=True)

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
NK = input().split(' ')
N = int(NK[0])
K = int(NK[1])
H = input().split(' ')

H = [int(s) for s in H]

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

Submission status: Accepted

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

if __name__=="__main__":
    main()

Submission status: Accepted

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


def solve(N: int, K: int, H: "List[int]"):
    H.sort()
    H.reverse()
    return sum(h for h in H[K:])


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

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
arr1 = str(input())
arr = arr1.split()
n = int( arr[0] )
k = int( arr[1] )

if k >= n :
    print(0)
else:
    totalMonster1 = str( input() )
    totalMonster  = totalMonster1.split()
    tMonster = []
    for i in totalMonster:
        tMonster.append(int(i))
    tM1 = sorted(tMonster)
    tM = tM1[::-1]
    tM = tM[k:]
    #print(tM)
    print(sum(tM))

Submission status: Accepted

Solution code:
import numpy as np

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# Input(n = num of monsters/k = num of special attacks)
n, k = map(int, input().split())
monsters = sorted(list(map(int, input().split())), reverse=True)
# NOTE: The sorted() function is in an ascending order in default.
# NOTE: And it's reversed, so now it's in a descending order.

# Calculating and judging the minimal number of attacks fennec needs to win.
if len(monsters) <= k:
    print(0)
else:
    EntireMonsters = sum(monsters)
    destroyed = sum(monsters[:k])
    print(EntireMonsters - destroyed)

Submission status: Accepted

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


def solve(N: int, K: int, H: "List[int]"):
    print(sum(sorted(H,reverse=True)[K:]))


# 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:
H,K=map(int,input().split())
L=sorted(list(map(int,input().split())),reverse=True)
if len(L) <= K:
  print(0)
else:
  SL=sum(L)
  MK=sum(L[:K])
  print(SL-MK)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math

EnemyCount, slayeCount = map(int, input().split())
enemyHealths = list(map(int, input().split(" ")))
enemyHealths.sort()

if EnemyCount < slayeCount:
    slayeCount = EnemyCount

for _ in range(slayeCount):
    del enemyHealths[-1]

print(sum(enemyHealths))

Submission status: Accepted

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

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

Submission status: Accepted

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

del hlis[0:k]
print(sum(hlis))

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,k = [int(x) for x in input().split()]
m = [int(x) for x in input().split()]
m.sort()
if n<k:
  k = n
print(sum(m[0:n-k]))

Submission status: Accepted

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

Submission status: Accepted

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

print(sum(H))

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
S = 0
for i in range(0, K):
    if len(A) > 0:
        A.pop(-1)
print(sum(A))

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
lines = sys.stdin.readlines()
n, k = [int(i) for i in lines[0].rstrip().split(" ")]
h = [int(i) for i in lines[1].rstrip().split(" ")]

h.sort()
h.reverse()

print(sum(h[k:]))

Submission status: Accepted

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

h.sort(reverse=True)

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

Submission status: Accepted

Solution code:
#N: モンスターの数, K: 必殺技を使える回数
N, K = map(int,input().split())
#i番目のモンスターの体力
H_list = list(map(int, input().split()))

#攻撃回数の最小値を求める
#1. モンスターの体力の合計を求める。
#２．多い順にK個の体力の合計値を求める。
#３．体力の全合計からK番目までの合計の差を求める。

H_sum = sum(H_list) 

Hk_sum = 0
H_list = sorted(H_list, reverse=True)
rep = K if K< N else N
for i in range(rep):
    Hk_sum += H_list[i]
    
Attack_num = H_sum - Hk_sum

print(Attack_num)

Submission status: Accepted

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

if k > n:
    k = n

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()))
if n<=k:
  print("0")
  exit()
new_h = sorted(h)
for i in range(k):
  new_h.pop(-1)
print(sum(new_h))

Submission status: Accepted

Solution code:
import numpy as np
N, K = [int(i) for i in input().split()]
H = [int(i) for i in input().split()]

sorted_H = sorted(H)
num = np.maximum(0, N-K)
answer = sum(sorted_H[:num])
print(answer)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
ans = 0
for i in range(len(a)-m):
  ans += a[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 = ans + H[i]
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

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(reverse=True)
  for i in range(K):
    h[i] = 0
  for i in range(N):
    ans += h[i]
  print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

read = sys.stdin.buffer.read
input = sys.stdin.buffer.readline
inputs = sys.stdin.buffer.readlines

#mod=10**9+7
# rstrip().decode('utf-8')
# map(int,input().split())
#import numpy as np


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

if __name__ == "__main__":
	main()

Submission status: Accepted

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

sn = sum(a[k:])

print(sn)

Submission status: Accepted

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

N, K = D[0], D[1]
NewH = sorted(H, reverse = True)
print(sum(NewH[K:]))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#coding:utf-8
N, K = map(int, input().split())
H = list(map(int, input().split()))
H.sort()
#print (H)
idx = max(len(H)-K,0)
print (sum(H[:idx]))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

if __name__=='__main__':
  main()

Submission status: Accepted

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

if k >= len(l):
  print(0)
else:
  print(sum(l[k:]))

Submission status: Accepted

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

if k >= len(l):
  print(0)
else:
  print(sum(l[k:]))

Submission status: Accepted

Solution code:
eneNum, spNum = map(int, input().split())
eneHp = map(int, input().split())
eneHpList = list(eneHp)

# TLE
#count = 0
#for i in range(spNum):
#    if len(eneHpList) > 0:
#        maxEneHp = max(eneHpList)
#        eneHpList.remove(maxEneHp)

# new method
eneHpList.sort()
eneHpList.reverse()
del eneHpList[0:min([spNum, len(eneHpList)])]
count = sum(eneHpList)

print("{}".format(count))

Submission status: Accepted

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

hs=sorted(h)
if n<=k:
  print('0')
else:
  print(sum(hs[:n-k]))

Submission status: Accepted

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


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


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, K = MAP()
H = sorted(LIST())

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

Submission status: Accepted

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, K = MAP()
H = LIST()
H.sort()

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

Submission status: Accepted

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