Problem:


Score : 300 points

Problem Statement

Fennec is fighting with N monsters.

The health of the i-th monster is H_i.

Fennec can do the following two actions:

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

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

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

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

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

Constraints

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

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

1 \leq H_i \leq 10^9

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N K
H_1 ... H_N

Output

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

Sample Input 1

3 1
4 1 5

Sample Output 1

5

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

Sample Input 2

8 9
7 9 3 2 3 8 4 6

Sample Output 2

0

She can use Special Move on all the monsters.

Sample Input 3

3 0
1000000000 1000000000 1000000000

Sample Output 3

3000000000

Watch out for overflow.



Sample input:
3 1
4 1 5


Sample output:
5

Submission status: Accepted

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

h = sorted(h, reverse=True)

ans = 0
cnt = 0

for i in h:
    cnt += 1
    if cnt <= k:
        continue
    else:
        ans += i

print(ans)

Submission status: Accepted

Solution code:
import math
n,m = map(int, input().split())
a=list(map(int,input().split()))
a.sort()
ans=0
ans=sum(a[:n-m])
print(ans if n>m else "0")

Submission status: Accepted

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

import array
from bisect import *
from collections import *
import fractions
import heapq
from itertools import *
import math
import random
import re
import string
import sys

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

Submission status: Accepted

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

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

Submission status: Accepted

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

h.sort()
for i in range(min(k,n)):
    h.pop()
print(sum(h))

Submission status: Accepted

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

hLen = len(H)
if hLen <= K:
    print(0)
    sys.exit(0)

H.sort()

print(sum(H[:hLen-K]))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

h.sort()
print(sum(h[::-1][k:]))

Submission status: Accepted

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

    h.sort()
    if k >= n:
        print(0)
        return
    for i in range(1,k+1):
        h.pop(-1)
    print(sum(h))
if __name__=='__main__':
    main()

Submission status: Accepted

Solution code:
import numpy as np

N, K = map(int, input().split())
H = sorted(list(map(int, input().split())))[::-1]
H = np.array(H)

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

print(ans)

Submission status: Accepted

Solution code:
''' Hey stalker :) '''
INF = 10**10
def main():
    print = out.append
    ''' Cook your dish here! '''
    n, k = get_list()
    li = get_list()
    li.sort(reverse=True)
    #res = min(n, k)
    res = sum(li[k:])
    print(res)



''' Pythonista fLite 1.1 '''
import sys
#from collections import defaultdict, Counter
#from bisect import bisect_left, bisect_right
#from functools import reduce
#import math
input = iter(sys.stdin.buffer.read().decode().splitlines()).__next__
out = []
get_int = lambda: int(input())
get_list = lambda: list(map(int, input().split()))
main()
#[main() for _ in range(int(input()))]
print(*out, sep='\n')

Submission status: Accepted

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

H.sort()
sm=0

for tmp in range(len(H)-k):
    sm+=H[tmp]

print(sm)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    n, k = map(int, input().split())
    hit_list = list(map(int, input().split()))

    hit_list.sort(reverse=True)

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

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

    print(sum(hit_list))

if __name__ == '__main__':
    main()

Submission status: Accepted

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

H_list.sort()
print(sum(H_list[:max(0, N - K)]))

Submission status: Accepted

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

Submission status: Accepted

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

H.sort(reverse=True)

# print('-----output-----')
print(sum(H[K:]))

Submission status: Accepted

Solution code:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
# from fractions import gcd
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from functools import reduce
from bisect import bisect_left, insort_left
from heapq import heapify, heappush, heappop

INPUT = lambda: sys.stdin.readline().rstrip()
INT = lambda: int(INPUT())
MAP = lambda: map(int, INPUT().split())
S_MAP = lambda: map(str, INPUT().split())
LIST = lambda: list(map(int, INPUT().split()))
S_LIST = lambda: list(map(str, INPUT().split()))

sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7


def main():
    N, K = MAP()
    H = LIST()
    if N <= K:
        print(0)
        sys.exit()

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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
num_monster, num_trick = map(int, input().split())
hps = list(map(int, input().split()))

hps.sort(reverse=True)
to_attack = hps[num_trick:]

print(sum(to_attack))

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
inputs = input().split(" ")
n = int(inputs[0])
k = int(inputs[1])
h = input().split(" ")
for i in range(n):
    h[i] = int(h[i])
h = sorted(h)[::-1]

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

print(all)

Submission status: Accepted

Solution code:
from sys import stdin
#from collections import deque
#from math import ceil


def ii(): return int(stdin.readline())


def fi(): return float(stdin.readline())


def mi(): return map(int, stdin.readline().split())


def fmi(): return map(float, stdin.readline().split())


def li(): return list(mi())


def lsi():
    x=list(stdin.readline())
    x.pop()
    return x


def si(): return stdin.readline()


def sieve(x):
    a=[True]*(x+1)
    sq=floor(sqrt(x))
    for i in range(3, sq+1, 2):
        if a[i]:
            for j in range(i*i, x+1, i):
                a[j]=False
    if x>1:
        p=[2]
    else:
        p=[]
    for i in range(3, x+1, 2):
        if a[i]:
            p.append(i)
    return p
#vowel={'a', 'e', 'i', 'o', 'u', 'y', 'A', 'E', 'I', 'O', 'U', 'Y'}
#pow=[1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576, 2097152, 4194304, 8388608, 16777216, 33554432, 67108864, 134217728, 268435456, 536870912, 1073741824, 2147483648, 4294967296, 8589934592, 17179869184, 34359738368, 68719476736, 137438953472, 274877906944, 549755813888, 1099511627776, 2199023255552, 4398046511104, 8796093022208, 17592186044416, 35184372088832, 70368744177664, 140737488355328, 281474976710656, 562949953421312, 1125899906842624, 2251799813685248, 4503599627370496, 9007199254740992, 18014398509481984, 36028797018963968, 72057594037927936, 144115188075855872, 288230376151711744, 576460752303423488, 1152921504606846976, 2305843009213693952, 4611686018427387904, 9223372036854775808]
############# CODE STARTS HERE #############
n, m=mi()
a=li()
a.sort(reverse=True)
m=min(n, m)
print(sum(a[m:]))

Submission status: Accepted

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

h.sort(reverse=True)

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

print(sum(h[k:]))

Submission status: Accepted

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

h.sort()

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

Submission status: Accepted

Solution code:
from sys import stdin
n, k = map(int, stdin.readline().rstrip().split())
hp = list(map(int, stdin.readline().rstrip().split()))
hp.sort(reverse=True)
print(sum(hp[k:]))

Submission status: Accepted

Solution code:
from sys import stdin


def fetch_one_line():
    return stdin.readline().rstrip()


def fetch_int_input():
    return [int(s) for s in fetch_one_line().split()]


def fetch_inputs(times):
    return [fetch_one_line() for _ in range(times)]


def fetch_int_inputs(times):
    return [[int(s) for s in fetch_one_line()] for _ in range(times)]


def fetch_ints_inputs(times):
    return [fetch_int_input() for _ in range(times)]


N, K = fetch_int_input()
hps = fetch_int_input()

sort_hps = sorted(hps, reverse=True)

remain_hps = sort_hps[K:]
print(sum(remain_hps))

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
for i in range(k):
    a.pop()
    if len(a)==0:
        break
print("0" if len(a)==0 else sum(a))

Submission status: Accepted

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

h.sort(reverse=True)

print(sum(h[k:]))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,K=[int(i) for i in input().split()]
H=sorted([int(i) for i in input().split()])[::-1]
H=H[K:]
print(sum(H))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,k = map(int,input().split())
a = list(map(int,input().split()))
a.sort(reverse = 1)
# print(a)
x = min(k,n)
print(sum(a[x:]))

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(1000000000)
import math
from fractions import gcd
from itertools import count, permutations
from functools import lru_cache
from collections import deque, defaultdict
from pprint import pprint
ii = lambda: int(input())
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())
INF = float('inf')
N1097 = 10**9 + 7

def meg(f, ok, ng):
    while abs(ok-ng)>1:
        mid = (ok+ng)//2
        if f(mid):
            ok=mid
        else:
            ng=mid
    return ok
#

def main():
    N,K=mis()
    H=lmis()
    H.sort(reverse=True)
    print(sum(H[K:]))

main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

h_sort = sorted(h, reverse=True)

print(sum(h_sort[k:]))

Submission status: Accepted

Solution code:
h,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:
import sys
sys.setrecursionlimit(4100000)

import math

import logging

logging.basicConfig(level=logging.DEBUG)

logger = logging.getLogger(__name__)


def resolve():
    # S = [x for x in sys.stdin.readline().split()][0]  # 文字列 一つ
    # N = [int(x) for x in sys.stdin.readline().split()][0]  # int 一つ
    N, K = [int(x) for x in sys.stdin.readline().split()]  # 複数int
    h_list = [int(x) for x in sys.stdin.readline().split()]  # 複数int

    # grid = [list(sys.stdin.readline().split()[0]) for _ in range(N)]  # 文字列grid
    # grid = [[int(x) for x in sys.stdin.readline().split()]
    #         for _ in range(N)]  # int grid

    logger.debug('{}'.format([]))

    h_list = sorted(h_list, reverse=True)

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


if __name__ == "__main__":
    resolve()

# AtCoder Unit Test で自動生成できる, 最後のunittest.main は消す
# python -m unittest template/template.py で実行できる
# pypy3 -m unittest template/template.py で実行できる

import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """3 1
4 1 5"""
        output = """5"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """8 9
7 9 3 2 3 8 4 6"""
        output = """0"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """3 0
1000000000 1000000000 1000000000"""
        output = """3000000000"""
        self.assertIO(input, output)

Submission status: Accepted

Solution code:
A,B=map(int,input().split())
C=list(map(int,input().split()))
C.sort(reverse=True)
print(sum(C[B:]))

Submission status: Accepted

Solution code:
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

h,n = mi()
a = li()
a.sort()
if n >= h:
    print(0)
else:
    ans = 0
    for i in range(h-n):
        ans += a[i]
    print(ans)

Submission status: Accepted

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

h = sorted(h)
h.reverse()
h = h[k:]
print(sum(h))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,k = map(int,input().split())
H = [int(i) for i in input().split()]
H.sort(reverse = True)
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_array = list(map(int, input().split()))
h_array.sort()
for _ in range(min(k, n)):
    h_array.pop()
print(sum(h_array))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,K = map(int,input().split())
h = [int(s) for s in input().split()]
t = sorted(h,reverse = True)
p = t[K:N]
s = sum(p)
print(s)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
h=list(map(int,input().split()))
h.sort(reverse=1)
ans=0
for x in h:
  if k>=1:
    k-=1
  else:
    ans+=x







print(ans)

Submission status: Accepted

Solution code:
#!/bin/bash
''':'
docker run --rm -it -v $(cd $(dirname $0) && pwd):/vo:ro pypy:3-2.4.0 \
   /bin/bash -c "pypy3 /vo/$(basename $0) < /vo/g.inp"
exit $?
'''
import sys


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


def main():
    n, k = _ia()
    h = _ia()
    if n <= k:
        return 0

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


print(main())

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

H = sorted(H, reverse=True)
if len(H) <= K:
    print(0)

else:
    print(sum(H[K:]))

Submission status: Accepted

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

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

hl = sorted(hl)
if n <= k:
    print(0)
elif k== 0:
    print(sum(hl))
else:
    print(sum(hl[:-k]))

Submission status: Accepted

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


if __name__ == '__main__':
    resolve()

Submission status: Accepted

Solution code:
def solve(n, k, h_list):
    h_list_s = list(sorted(h_list))
    if k >= n:
        return 0
    elif k > 0:
        return sum(h_list_s[:-k])
    else:
        return sum(h_list_s)


def main():
    n, k = map(int, input().split())
    h_list = list(map(int, input().split()))
    res = solve(n, k, h_list)
    print(res)


def test():
    assert solve(3, 1, [4, 1, 5]) == 5
    assert solve(8, 9, [7, 9, 3, 2, 8, 4, 6]) == 0
    assert solve(3, 0, [1000000000, 1000000000, 1000000000]) == 3000000000


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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

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

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

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

Submission status: Accepted

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

print(count)

Submission status: Accepted

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

n = sum(h[k:])

print(n)

Submission status: Accepted

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

N, K, *H = map(int, read().split())

H = sorted(H)[::-1]
cnt = 0
for i in range(min(K, N), N, 1):
    cnt += H[i]

print(cnt)

Submission status: Accepted

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

A = sorted(map(int, input().split(" ")), reverse=True)

print(sum(A[K:]))

Submission status: Accepted

Solution code:
from sys import stdout
printn = lambda x: stdout.write(str(x))
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 999999999
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

n,k = inm()
h = inl()
if n<=k:
    print(0)
    exit()
h.sort()
print(sum(h[:(n-k)]))

Submission status: Accepted

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


H.sort(reverse=True)

ans = 0

for i in range(K, len(H), 1):

    ans = 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(H)
H = H[K:]
#print(H)

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

Submission status: Accepted

Solution code:
from sys import stdin

if __name__ == '__main__':
    n, k = [int(x) for x in stdin.readline().rstrip().split()]
    H = [int(x) for x in stdin.readline().rstrip().split()]
    H.sort(reverse=True)
    H = H[k:]
    totalAttack = sum(H)
    print(totalAttack)

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())
lst = list(map(int, input().split()))
sor = sorted(lst, reverse=True)
if k >= n:
    print(0)
else:
    new = sor[k:]
    print(sum(new))

Submission status: Accepted

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

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

Submission status: Accepted

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

if K == 0:
    print(sum(H))
    exit()

H.sort()

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

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_list.sort(reverse=True)
    print(sum(h_list[k:]))

Submission status: Accepted

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


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

Submission status: Accepted

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

nlist.sort(reverse=False)

for i in range (b):
    if len(nlist) == 0:
        break
    nlist.pop()

print(sum(nlist))

Submission status: Accepted

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

print(sum(hList[k:]))

Submission status: Accepted

Solution code:
import sys


def main():
    n_and_k_s = sys.stdin.readline().strip().split(' ')
    n, k = [int(s) for s in n_and_k_s]
    h = [int(s) for s in sys.stdin.readline().strip().split(' ')]

    h.sort(reverse=True)

    total = 0
    special = 0
    for i in range(len(h)):
        if special < k:
            special += 1
            continue
        total += h[i]
    print(total)


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 = sorted(H,reverse=True)
    H = H[K:]
    print(sum(H))

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

Submission status: Accepted

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

Submission status: Accepted

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

if n <= k:
    print(0)
elif k != 0:
    h.sort()
    ans = sum(h[:-k])
    print(ans)
else:
    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(sum(H[K:]))
else:
  print(0)

Submission status: Accepted

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

Submission status: Accepted

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

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:
def main():
    N, K = map(int, input().split())
    H = list(map(int, input().split()))
    H.sort()
    H = H[0:N-K:]

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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys

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

if N < K:
    print('0')
    sys.exit(0)

HList.sort()

result = 0
for i in range(N - K - 1, -1, -1):
    result += HList[i]
    

print(result)

Submission status: Accepted

Solution code:
import collections
import math
import operator as op
from functools import reduce
import numpy as np
import math
import bisect
import heapq


MOD = 1000000007


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


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


def get_inputs(cast_func=None):
    if cast_func is None:
        return input().split()
    else:
        return list(map(cast_func, input().split()))


def get_input(cast_func=None):
    if cast_func is None:
        return input()
    else:
        return cast_func(input())


def is_prime(n):
    if n == 1:
        return False
    for i in range(2, int(n**0.5)+1):
        if n % i == 0:
            return False
    return True


def main():
    N, K = get_inputs(int)
    H = get_inputs(int)

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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math

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

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

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

ans = 0
N,K = splitintinput()
H = listintinput()
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 = list(map(int, input().split()))
H.sort()

for i in range(K):
    if len(H) == 0:
        break
    H.pop()

count = sum(H)
print(count)