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: Wrong Answer

Solution code:
def add_num(List):
  res=0
  for y in List:
    res += y
  print(res)

N, K=map(int,input().split())
List=list(map(int,input().split()))
if N < K:
  print(0)
elif K is not 0:
  x=List.index(max(List))
  List.pop(x)
  add_num(List)
else:
  add_num(List)

Submission status: Wrong Answer

Solution code:
def add_num(List):
  res=0
  for y in List:
    res += y
  print(res)

N, K=map(int,input().split())
List=list(map(int,input().split()))
if N <= K:
  print(0)
elif K is not 0:
  x=List.index(max(List))
  List.pop(x)
  add_num(List)
else:
  add_num(List)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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


def solve(N: int, K: int, H: "List[int]"):
    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: Wrong Answer

Solution code:
# Input(n = num of monsters/k = num of special attacks)
n, k = input().split()
a = list(map(int, input().split()))

# Variable declarations
n = int(n)
k = int(k)
attacks = 0

# Calculating how many attacks fennec needs.
for i in range(n-k):
    if k >= n:
        print(0)
    attacks += a[i]

# Printing how many attacks fennec needs.
print(attacks)

Submission status: Wrong Answer

Solution code:
# Input(n = num of monsters/k = num of special attacks)
n, k = input().split()
a = list(map(int, input().split()))

# Variable declarations
n = int(n)
k = int(k)
attacks = 0

# Calculating how many attacks fennec needs.
for i in range(n-k):
    if k > n:
        print(0)
    attacks += a[i]

# Printing how many attacks fennec needs.
print(attacks)

Submission status: Wrong Answer

Solution code:
# Input(n = num of monsters/k = num of special attacks)
n, k = input().split()
a = list(map(int, input().split()))

# Variable declarations
n = int(n)
k = int(k)
attacks = 0

# Calculating how many attacks fennec needs.
for i in range(n-k):
    if k > n:
        break
    attacks += a[i]

# Printing how many attacks fennec needs.
print(attacks)

Submission status: Wrong Answer

Solution code:
# Input(n = num of monsters/k = num of special attacks)
n, k = input().split()
a = list(map(int, input().split()))

# Variable declarations
n = int(n)
k = int(k)
attacks = 0

# Calculating how many attacks fennec needs.
for i in range(n-k):
    attacks += a[i]

# Printing how many attacks fennec needs.
print(attacks)

Submission status: Wrong Answer

Solution code:
H,K=map(int,input().split())
L=list(map(int,input().split()))
SL=sum(L)
M=max(L)
print(SL-M)

Submission status: Wrong Answer

Solution code:
import math

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

if EnemyCount < slayeCount:
    slayeCount = EnemyCount

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

print(sum(enemyHealths))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N,K = map(int,input().split())
H = list(map(int,input().split()))
H.sort()
H.reverse()
if K==0:
        pass
elif K==1:
        del H[0]
else:
   del H[0:K-1]
a = 0

for i in H:
        a+=i
print(int(a))

Submission status: Wrong Answer

Solution code:
N,K = map(int,input().split())
H = list(map(int,input().split()))
H.sort()
H.reverse()
if K==0:
        pass
elif K==1:
        del H[0]
else:
   del H[0:K-1]
a = 0

for i in H:
        a+=i
print(a)

Submission status: Wrong Answer

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.reverse()
del eneHpList[0:min([spNum, len(eneHpList)])]
count = sum(eneHpList)

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

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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.reverse()
del eneHpList[0:spNum]
count = sum(eneHpList)

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

Submission status: Wrong Answer

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

H,A = map(int,input().split(" "))
Alist=[]
Alist =  list(map(int,input().split(" ")))
Alist = sorted(Alist)

if A >= len(Alist):
    print("0")
elif A == 0:
    print(sum(Alist))
else:
    del Alist [-(len(Alist)-A)+1:]
    print(sum(Alist))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

for i in range(K):
    if len(H)!=0:
        H.remove(max(H))
        #print(H)
    else:
        #print(0)
        break
print(sum(H))'''

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

print(sum(H[K+1:]))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N,K=map(int,input().split())
if K>=N:
	print(0)
	quit()
L = [int(x) for x in input().split()]
L.sort()
if K:
	print(sum(L[:-K]))
print(sum(L))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!

n, k = map(int, input().split())
hs = list(map(int, input().split()))
hs.sort()
if (n <= k):
  print(0)
else:
  print(sum(hs[k:]))

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split(' '))
numlist = input().split(' ')
numlist.sort()
if N <= K:
  print(0)
else:
  numsub = numlist[:N - K + 1]
  numsub_i = [int(s) for s in numsub]
  print(sum(numsub_i))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N, K, *H = map(int, open(0).read().split())

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

Submission status: Wrong Answer

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

a.sort()

print(sum(a[:-k]))

Submission status: Wrong Answer

Solution code:
# coding utf-8
import math

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

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

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

print(ans)

Submission status: Wrong Answer

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


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

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

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

print(ans)

Submission status: Wrong Answer

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


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

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

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

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,k = map(int, input().split())
L = list(map(int,input().split()))
ans = 0
S = sorted(L)
print(S)
for i in range(n):
    if k > 0:
        del S[-1]
        k = k-1
print(S)
print(sum(S))

Submission status: Wrong Answer

Solution code:
n,k = map(int, input().split())
L = list(map(int,input().split()))
ans = 0
S = sorted(L,reverse=True)
print(S)
for i in range(n):
    if k > 0:
       # ans += 1 
       k = k-1
    elif k == 0:
        ans = ans+S[i]
print(ans)

Submission status: Wrong Answer

Solution code:
N, K = map(int,input().split())
N_hp = list(map(int,input().split()))
N_hp.sort(reverse=True)
del N_hp[:K]
sum_turn = sum(N_hp)
print(K+sum_turn)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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


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

    total = sum(h)

    if k >= n:
        print(0)
    elif k == 0:
        print(total)
    else:
        print(sum(sorted(h[k + 1:], reverse=True)))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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


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

    total = sum(h)

    if k >= n:
        print(0)
    elif k == 0:
        print(total)
    else:
        print(total - sum(sorted(h[k + 1:], reverse=True)))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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


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

    total = sum(h)

    if k >= n:
        print(0)
    elif k == 0:
        print(total)
    else:
        print(total - sum(sorted(h[:k + 1], reverse=True)))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# coding: utf-8
n, k = map(int, input().split())
h = list(map(int, input().split()))
h.sort()
if n <= k:
    print(n)
else:
    print(sum(h[0: n - k]) + k)

Submission status: Wrong Answer

Solution code:
num_enemies, count_hissatsu = [int(i) for i in input().split(' ')]
enemies = sorted([int(k) for k in input().split(' ')])[:-1*count_hissatsu]


print(sum(enemies))

Submission status: Wrong Answer

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

if n<=m:
  print(0)
else:
  a=a[-(n-m):]
  print(sum(a))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if len(a)<=m:
  print(0)
else:
  a=a[:-m]
  print(sum(a))

Submission status: Wrong Answer

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

if len(v) <= K:
  print(0)
else:
  print(sum(v[-K:]))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
input_num=input()
n=input_num.split()
num = list(map(int,n))

if len(num)-2<=num[1]:
  print(0)
else:
  a=num[2:]
  a.sort(reverse=True)
  b=a[num[1]:]
  print(sum(b))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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


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

Submission status: Wrong Answer

Solution code:
N,K=input().split()
H=input()
H=H.split()
SUM=sum(int(i) for i in H)
A=(sorted(H, reverse=True)[:int(K)])
ASUM=sum(int(i) for i in A)
LO=int(SUM)-int(ASUM)
if(int(LO)<0):
  print(0)
elif(K>N):
  print(0)
else:
  print(LO)

Submission status: Wrong Answer

Solution code:
H, N = map(int, input().split())
A = [int(x) for x in input().split()]
print(A)
list2 = sorted(A, reverse=True)  # reverseをTrueに
print(list2)
if N>0:
    del list2[0:N]
    print(list2)
    print(sum(list2))
elif N<0:
    print(sum(A))

Submission status: Wrong Answer

Solution code:
n,k = map(int,input().split())
arr = list(map(int,input().split()))
arr.sort(reverse=True)
if k >= n :
  print(0)
elif k == 0 :
  print(sum(arr))
else :
  for i in range(k) :
    arr[i] = -1
  arr.remove(-1)
  print(sum(arr))

Submission status: Wrong Answer

Solution code:
input_line = list(map(int,input().split()))
input_hp = list(map(int,input().split()))

if input_line[0] <= input_line[1]:
    print('0')
else:
    input_hp.sort(reverse=True)
    if input_line[1] == 0:
        result_input_hp = len(input_hp) - input_line[1]
    else:
        result_input_hp = len(input_hp) - input_line[1] - 1
    sum_total = sum(input_hp[:result_input_hp])
    print(sum_total)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

# Input
s = [input() for i in range(2)]
NK = list(s[0].split())
HI = list(s[1].split())
HI.sort(reverse=True)

# Proccess
survibe_monster = int(NK[0])-int(NK[1])
killed_monster = int(NK[1])

del HI[:killed_monster]

how_many_attack = 0
for i in range(survibe_monster):
  how_many_attack = how_many_attack + int(HI[i])

# Output                   
print(how_many_attack)

Submission status: Wrong Answer

Solution code:
import sys

def propare():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))
    K = int(next(tokens))
    H_list = []
    for i in range(N):
        H_list.append(int(next(tokens)))

    solve(N, K, H_list)

def solve(H: int, N: int, H_list: list):
    H_ranking_list = sorted(H_list, reverse=True)
    if N != 0:
        H_ranking_list = H_ranking_list[N-1:]

    count = sum(H_ranking_list)

    print(count)

    return
 
if __name__ == "__main__":
    propare()

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
if(n<=k):
  print(0)
  exit()

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

Submission status: Wrong Answer

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

# Input
s = [input() for i in range(2)]
NK = list(s[0].split())
HI = sorted(list(s[1].split()))

# Proccess
nk = int(NK[0])-int(NK[1])
del HI[nk:]

x = 0
for i in range(nk):
  x = x + int(HI[i])

# Output                            
print(x)

Submission status: Wrong Answer

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

print(n)
print(k)
print(h)

s = 0

i = 0
while i < len(h)-k:
  s += h[i]
  i += 1

print(s)

Submission status: Wrong Answer

Solution code:
from heapq import heappush,heappop,heapify
from collections import deque,defaultdict,Counter
import itertools
from itertools import permutations,combinations,groupby
import sys
import bisect
import string
import math
import time
import random
def S_():
    return input()
def LS():
    return [i for i in input().split()]
def I():
    return int(input())
def MI():
    return map(int,input().split())
def LI():
    return [int(i) for i in input().split()]
def LI_():
    return [int(i)-1 for i in input().split()]
def NI(n):
    return [int(input()) for i in range(n)]
def NI_(n):
    return [int(input())-1 for i in range(n)]
def StoI():
    return [ord(i)-97 for i in input()]
def ItoS(nn):
    return chr(nn+97)
def LtoS(ls):
    return ''.join([chr(i+97) for i in ls])
def GI(V,E,Directed=False,index=0):
    org_inp=[]
    g=[[] for i in range(n)]
    for i in range(E):
        inp=LI()
        org_inp.append(inp)
        if index==0:
            inp[0]-=1
            inp[1]-=1
        if len(inp)==2:
            a,b=inp
            g[a].append(b)
            if not Directed:
                g[b].append(a)
        elif len(inp)==3:
            a,b,c=inp
            aa=(inp[0],inp[2])
            bb=(inp[1],inp[2])
            g[a].append(bb)
            if not Directed:
                g[b].append(aa)
    return g,org_inp
def GGI(h,w,search=None,replacement_of_found='.',mp_def={'#':1,'.':0}):
#h,w,g,sg=GGI(h,w,search=['S','G'],replacement_of_found='.',mp_def={'#':1,'.':0}) # sample usage
    mp=[1]*(w+2)
    found={}
    for i in range(h):
        s=input()
        for char in search:
            if char in s:
                found[char]=((i+1)*(w+2)+s.index(char)+1)
                mp_def[char]=mp_def[replacement_of_found]
        mp+=[1]+[mp_def[j] for j in s]+[1]
    mp+=[1]*(w+2)
    return h+2,w+2,mp,found
def bit_combination(k,n=2):
    rt=[]
    for tb in range(n**k):
        s=[tb//(n**bt)%n for bt in range(k)]
        rt+=[s]
    return rt
def show(*inp,end='\n'):
    if show_flg:
        print(*inp,end=end)
YN=['Yes','No']
mo=10**9+7
inf=float('inf')
l_alp=string.ascii_lowercase
u_alp=string.ascii_uppercase
ts=time.time()
sys.setrecursionlimit(10**7)
input=lambda: sys.stdin.readline().rstrip()

def ran_input():
    import random
    n=random.randint(4,16)
    rmin,rmax=1,10
    a=[random.randint(rmin,rmax) for _ in range(n)]
    return n,a

show_flg=False
show_flg=True

ans=0

n,k=LI()
h=sorted(LI())
ans=sum(h[:n-k])

print(ans)

Submission status: Wrong Answer

Solution code:
from heapq import heappush,heappop,heapify
from collections import deque,defaultdict,Counter
import itertools
from itertools import permutations,combinations,groupby
import sys
import bisect
import string
import math
import time
import random
def S_():
    return input()
def LS():
    return [i for i in input().split()]
def I():
    return int(input())
def MI():
    return map(int,input().split())
def LI():
    return [int(i) for i in input().split()]
def LI_():
    return [int(i)-1 for i in input().split()]
def NI(n):
    return [int(input()) for i in range(n)]
def NI_(n):
    return [int(input())-1 for i in range(n)]
def StoI():
    return [ord(i)-97 for i in input()]
def ItoS(nn):
    return chr(nn+97)
def LtoS(ls):
    return ''.join([chr(i+97) for i in ls])
def GI(V,E,Directed=False,index=0):
    org_inp=[]
    g=[[] for i in range(n)]
    for i in range(E):
        inp=LI()
        org_inp.append(inp)
        if index==0:
            inp[0]-=1
            inp[1]-=1
        if len(inp)==2:
            a,b=inp
            g[a].append(b)
            if not Directed:
                g[b].append(a)
        elif len(inp)==3:
            a,b,c=inp
            aa=(inp[0],inp[2])
            bb=(inp[1],inp[2])
            g[a].append(bb)
            if not Directed:
                g[b].append(aa)
    return g,org_inp
def GGI(h,w,search=None,replacement_of_found='.',mp_def={'#':1,'.':0}):
#h,w,g,sg=GGI(h,w,search=['S','G'],replacement_of_found='.',mp_def={'#':1,'.':0}) # sample usage
    mp=[1]*(w+2)
    found={}
    for i in range(h):
        s=input()
        for char in search:
            if char in s:
                found[char]=((i+1)*(w+2)+s.index(char)+1)
                mp_def[char]=mp_def[replacement_of_found]
        mp+=[1]+[mp_def[j] for j in s]+[1]
    mp+=[1]*(w+2)
    return h+2,w+2,mp,found
def bit_combination(k,n=2):
    rt=[]
    for tb in range(n**k):
        s=[tb//(n**bt)%n for bt in range(k)]
        rt+=[s]
    return rt
def show(*inp,end='\n'):
    if show_flg:
        print(*inp,end=end)
YN=['Yes','No']
mo=10**9+7
inf=float('inf')
l_alp=string.ascii_lowercase
u_alp=string.ascii_uppercase
ts=time.time()
sys.setrecursionlimit(10**7)
input=lambda: sys.stdin.readline().rstrip()

def ran_input():
    import random
    n=random.randint(4,16)
    rmin,rmax=1,10
    a=[random.randint(rmin,rmax) for _ in range(n)]
    return n,a

show_flg=False
show_flg=True

ans=0

n,k=LI()
h=sorted(LI())
ans=sum(h[k:])

print(ans)

Submission status: Wrong Answer

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

# -*- coding: utf-8 -*-

def main():
    """
    ここでプログラムの解説を行う
     >>main()
    Hello world.
    0
    """
    s = list(map(int, input().split()))
    t = list(map(int, input().split()))

    a = 0  #勝つまでの回数
    b = s[0]#何匹か
    d = s[1]#必殺技の回数
    f = 0# Maxのいち
    for j in range(d):  #必殺技の回数
        c = sum(t)
        if c != 0:
            g = max(t)
            for i in range(b):
                if g == t[i]:
                    t[i] = 0
                    break
            t[f] = 0
            f = 0
        else:
            break
    a += sum(t)
    print(a)
    return 0

if __name__ == '__main__':

    #実際にmain()を呼び出して、結果を得て、その結果でPythonシステムを終える
    import sys
    sys.exit(main())

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import math


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

K = min(N,K)


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

data.sort()

total = sum( data[0:N-K] )

print(data)
print(total)

Submission status: Wrong Answer

Solution code:
import math


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

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

data.sort()

total = sum( data[0:N-K] )

print(total)

Submission status: Wrong Answer

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

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

if n <= k:
    print("0")
else:
    s_n = sorted(h_n, reverse=True)

    print(sum(s_n[:n - k]))

Submission status: Wrong Answer

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

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

if n <= k:
    print("0")
else:
    s_n = sorted(h_n, reverse=True)

    print(sum(s_n[:k]))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N, K = map(int,input().split())
H = list(input().split())
 
if K >= N:
    print(0)
elif N > K:
    if K == 0:
        print(sum(int(i) for i in H))
    else:
        H.remove(max(H))
        print(sum(int(i) for i in H))

Submission status: Wrong Answer

Solution code:
#!/user/bin/env python
#pythonプログラムであることを示している

# -*- coding: utf-8 -*-
"""
このプログラムはPythonを書く際のテンプレとなっています。これをコピペしてコーディングを行なってください。
なお字下げしないこと！！
"""

__author_ = 'Maruta Yuzuha'
__version_ = '1.0.0'
__date__ = '2019/12/25'

def main():
    """
    ここでプログラムの解説を行う
     >>main()
    Hello world.
    0
    """
    s = list(map(int, input().split()))
    t = list(map(int, input().split()))

    a = 0  #勝つまでの回数
    b = s[0]#何匹か
    d = s[1]#必殺技の回数
    f = 0# Maxのいち
    for j in range(d):  #必殺技の回数
        c = sum(t)
        if c != 0:
            g = max(t)
            for i in range(b):
                if g == t[i]:
                    t[i] = 0
                    break
            t[f] = 0
            f = 0
        else:
            break
    a += sum(t)
    print(a)
    return 0

if __name__ == '__main__':
    #上記のifの記述によってこのスクリプトファイルが起動された時だけ実行する部分になる。
    #ちなみにスクリプトが "モジュールとして"インポートされた時には実行されない、

    #単体テスト:モジュールのdocstring(ドキュメンテーション文字列)に記載された全ての対話実行例が書かれている通りに動作するかを確認
    #python ファイル名 -v
    import doctest
    doctest.testmod()

    #実際にmain()を呼び出して、結果を得て、その結果でPythonシステムを終える
    import sys
    sys.exit(main())

Submission status: Wrong Answer

Solution code:
import heapq

N,K = (int(x) for x in input().split())
H = list((-1)*(int(x)) for x in input().split())
heapq.heapify(H)
count = 0

for _ in range(K):
    if len(H) == 1:
        print(0)
        break

    heapq.heappop(H)
    count += 1

if len(H) != 1:
    sum = 0
    for _ in range(len(H)):
        sum -= heapq.heappop(H)

    print(sum)

elif len(H) == 1 and K == count:
    print(1)

Submission status: Wrong Answer

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

# N monsters
# No.i monster vitalitiy is Hi
# two actions
# attack : reduce 1 vitaility
# special: make vitality 0. Fenek can use K times of specials.

# print(H)
# print(f'N={N} K={K}')
if N <= K:
    print(0)
    exit()


H.sort(reverse=True)
# print(H)


r_H = H[K:]
# print(r_H)
print(sum(r_H))

sum_H = 0
for hp in r_H:
    sum_H += hp
print(sum_H)

# print(type(10**9))
# print(type(2*10**14))