Problem:


Score : 300 points

Problem Statement

Fennec is fighting with N monsters.

The health of the i-th monster is H_i.

Fennec can do the following two actions:

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

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

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

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

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

Constraints

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

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

1 \leq H_i \leq 10^9

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N K
H_1 ... H_N

Output

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

Sample Input 1

3 1
4 1 5

Sample Output 1

5

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

Sample Input 2

8 9
7 9 3 2 3 8 4 6

Sample Output 2

0

She can use Special Move on all the monsters.

Sample Input 3

3 0
1000000000 1000000000 1000000000

Sample Output 3

3000000000

Watch out for overflow.



Sample input:
3 1
4 1 5


Sample output:
5

Submission status: Accepted

Solution code:
import sys

input = sys.stdin.readline

ri = lambda: int(input())
rs = lambda: input().rstrip()
ril = lambda: list(map(int, input().split()))
rsl = lambda: input().rstrip().split()
ris = lambda n: [ri() for _ in range(n)]
rss = lambda n: [rs() for _ in range(n)]
rils = lambda n: [ril() for _ in range(n)]
rsls = lambda n: [rsl() for _ in range(n)]

n, k = ril()
ls = ril()
if n <= k:
    print(0)
    exit()
ls.sort()
if k > 0:
    ls = ls[:-k]
print(sum(ls))

Submission status: Accepted

Solution code:
import math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)

def s(generator, splitter, mapper):
    return [ mapper(s) for s in generator().split(splitter) ]

# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
    return [ int(s) for s in input().split(" ")]

# 改行区切りの入力をn行読み込んで数値リストにして返します。
def get_nums_n(n):
    return [ int(input()) for _ in range(n)]

n,k = get_nums_l()
hhh = sorted(get_nums_l(), reverse=True)

print(sum(hhh[k:]))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from math import ceil
n, k = map(int, input().split())
h_array = sorted([int(x) for x in input().split()])
if k >= n:
    print(0)
    exit()
print(sum(h_array[:n-k]))

Submission status: Accepted

Solution code:
import sys
import math
import heapq
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
DVSR = 1000000007
def POW(x, y): return pow(x, y, DVSR)
def INV(x, m=DVSR): return pow(x, m - 2, m)
def DIV(x, y, m=DVSR): return (x * INV(y, m)) % m
def LI(): return [int(x) 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 II(): return int(sys.stdin.readline())
def FLIST(n):
    res = [1]
    for i in range(1, n+1): res.append(res[i-1]*i%DVSR)
    return res

N,K=LI()
HS=LI()
HS.sort(reverse=True)
hcnt = 0
normal = 0
for i in range(N):
    if hcnt < K:
        hcnt += 1
    else:
        normal += HS[i]

print(normal)

Submission status: Accepted

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

H.sort()

for i in range(K):
    if H:
        H.pop()

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

Submission status: Accepted

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

H.sort(reverse=True)

Attack = H[K:]
print(sum(Attack))

Submission status: Accepted

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

Submission status: Accepted

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

print(sum(h[k:]))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline
INF = 2**62-1

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


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


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, K, H):
    H.sort()
    for _ in range(K):
        if H:
            H.pop()
    return sum(H)


def main():
    N, K = read_int_n()
    H = read_int_n()
    print(slv(N, K, H))


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n, k = map(int, raw_input().split())
hh = map(int, raw_input().split())
hh.sort()
print sum(hh[:-k if k else n])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, K = [int(s) for s in input().split()]
H = [int(s) for s in input().split()]
H.sort(reverse=True)
s = 0
for i in range(K,N):
    s += H[i]
print(s)

Submission status: Accepted

Solution code:
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
b.sort()
summ=0
for i in range(0,a[0]-a[1]):
    summ+=b[i]
print(summ)

Submission status: Accepted

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

H.sort(reverse=True)

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline
read = sys.stdin.read

#n,*w = [int(i) for i in read().split()]
#n,*t = map(int,read().split())

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

h.sort()

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
from collections import *
import heapq
import math
import bisect
from itertools import permutations,accumulate,combinations,product
from fractions import gcd
def input():
    return sys.stdin.readline()[:-1]
mod=10**9+7

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

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
N, K = [int(x) for x in input().split()]
H = [int(x) for x in input().split()]
H.sort()
if K >= N:
    print(0)
    sys.exit()
H = H[:N - K]
print(sum(H))

Submission status: Accepted

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

if k >= n:
    print(0)
else:
    A=sorted(A,reverse=True)
    print(sum(A[k:]))

Submission status: Accepted

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

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

H = sorted(H)

print(sum(H[0:len(H)-K]))

Submission status: Accepted

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

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

print (tmp)

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
nums = [int(i) for i in input().split()]
nums = sorted(nums)[::-1]
print(sum(nums[k:]))

Submission status: Accepted

Solution code:
# coding: utf-8
import re
import math
import fractions
import random
from heapq import heappop,heappush
import time
import sys
readline = sys.stdin.readline
#import numpy as np
mod=int(10**9+7)
inf=int(10**20)
class union_find():
    def __init__(self,n):
        self.n=n
        self.P=[a for a in range(N)]
        self.rank=[0]*n
 
    def find(self,x):
        if(x!=self.P[x]):self.P[x]=self.find(self.P[x])
        return self.P[x]
 
    def same(self,x,y):
        return self.find(x)==self.find(y)
 
    def link(self,x,y):
        if self.rank[x]<self.rank[y]:
            self.P[x]=y
        elif self.rank[y]<self.rank[x]:
            self.P[y]=x
        else:
            self.P[x]=y
            self.rank[y]+=1
 
    def unite(self,x,y):
        self.link(self.find(x),self.find(y))
 
    def size(self):
        S=set()
        for a in range(self.n):
            S.add(self.find(a))
        return len(S)
def bin_(num,size):
    A=[0]*size
    for a in range(size):
        if (num>>(size-a-1))&1==1:
            A[a]=1
        else:
            A[a]=0
    return A
def comb(n,r):return math.factorial(n)//math.factorial(n-r)//math.factorial(r)
def next_comb(num,size):
    x=num&(-num)
    y=num+x
    z=num&(~y)
    z//=x
    z=z>>1
    num=(y|z)
    if(num>=(1<<size)):return False
    else:
        return num
 

 
#main
n,k=map(int,input().split())
H=list(map(int,input().split()))
H.sort()
sum_=0
for a in range(n-k):
    sum_+=H[a]
print(sum_)

Submission status: Accepted

Solution code:
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n,k = LI()
    h = LI()
    if n <= k:
        print(0)
        return
    h.sort()
    ans = sum(h[:n-k])
    print(ans)
    return

#Solve
if __name__ == "__main__":
    solve()

Submission status: Accepted

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

print(sum(h[k:]))

Submission status: Accepted

Solution code:
import math
import fractions

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

def ValueToBits(x,digit):
    res = [0 for i in range(digit)]
    now = x
    for i in range(digit):
        res[i]=now%2
        now = now >> 1
    return res

def BitsToValue(arr):
    n = len(arr)
    ans = 0
    for i in range(n):
        ans+= arr[i] * 2**i
    return ans

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


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

a.sort()

for i in range(min(w,n)):
    a[n-1-i]=0
print(sum(a))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

H.sort()

ans=sum(H[:(N-K)])

if K>=N:
    ans=0

print(ans)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
input = sys.stdin.readline

n, k = [int(item) for item in input().split()]
h = [int(item) for item in input().split()]
h.sort(reverse=True)
h += [0] * (2 * 10**5)

print(sum(h[k:]))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math

def makelist(n, m):
    return [[0 for _ in range(m)] for _ in range(n)]

# n = int(input())
# 
# s = input()

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

hoge = max(0, N - K)
ans = sum(H[:hoge])
print(ans)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
n,k=map(int,input().split())
h=list(map(int,input().split()))
h.sort()
ans=0
for i in range(n-k):
    ans+=h[i]
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

H_list.sort()
H_list.reverse()

H_list = H_list[K:]

print(sum(H_list))

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:
# coding: utf-8
N, K = map(int, input().split())
H = list(map(int, input().split()))
H.sort(reverse=True)
ans = 0
for i in range(min(N, K)):
    H[i] = 0
print(sum(H))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys

N,K = map(int,input().split())
H = [int(x) for x in input().split()]
H.sort()

if K>=N:
    print(0)
    sys.exit()

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

print(cnt)

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
h = list(map(int, input().split()))
h = sorted(h)
if k >= n:
    print(0)
    exit()

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

def ri():
    return int(input())

def rl():
    return list(input().split())

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

def main():
    n, k = rli()
    lh = rli()
    lh.sort(reverse=True)
    ans = sum(lh[k:])
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
#!python3

iim = lambda: map(int, input().rstrip().split())

def resolve():
    N, K = iim()
    H = list(iim())
    H.sort(reverse=True)
    print(sum(H[K:]))

if __name__ == "__main__":
    resolve()

Submission status: Accepted

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

h = sorted(h)

left = n-k
ans = 0
if left >= 0:
	ans = sum(h[:left])
print(ans)

Submission status: Accepted

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

Hs.sort()
Hs.append(0)
print(sum(Hs[:-K-1]))

Submission status: Accepted

Solution code:
from sys import stdin
import math
n,k = [int(x) for x in stdin.readline().rstrip().split()]
li = list(map(int,stdin.readline().rstrip().split()))
li.sort()

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

Submission status: Accepted

Solution code:
import sys
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()))

n,k=MAP()
h=LIST()
h.sort()
if n-k<=0:
    print(0)
else:
    print(sum(h[:n-k]))

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

Submission status: Accepted

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

H.sort(reverse=True)

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

print(ans)

Submission status: Accepted

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

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

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

for h in H[k:]:
    ans += h
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

n,k = mii()
arr = limii()
if k >= len(arr):
    print(0)
    exit()
arr.sort(reverse=True)

print(sum(arr[k:]))

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def c_fennec_vs_monster():
    N, K = [int(i) for i in input().split()]
    H = [int(i) for i in input().split()]
    H.sort()
    for _ in range(K):
        if not H:
            break
        H.pop()
    return sum(H)

print(c_fennec_vs_monster())

Submission status: Accepted

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

main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
read = sys.stdin.read

n,k,*lst=map(int, read().split())
if k>=n:
  print(0)
  quit()
lst.sort(reverse=1)
s=sum(lst[k:])
print(s)

Submission status: Accepted

Solution code:
N,K = [int(zz) for zz in input().split()]
H = [int(zz) for zz in 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()))
lst.sort(reverse=True)
print(sum(lst[K:]))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

h.sort()

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:

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

H.sort()
L = len(H)
ans = sum(H[:max(0,L-K)])
print(ans)

Submission status: Accepted

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

hs.sort()

while hs and k:
    hs.pop()
    k -= 1

print sum(hs)

Submission status: Accepted

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


def main():
    N, K = map(int, input().split())
    Hs = list(map(int, input().split()))

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

    print(sum(remained))


if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import math
import itertools
import fractions
import heapq
import collections
import bisect
import sys
import copy

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

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
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()

n,k = LI()
h = LI()

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

Submission status: Accepted

Solution code:
import sys

n, k, *h = map(int, sys.stdin.read().split())

def main():
    h.sort(reverse=True)
    res = h[k:]
    return 0 if not res else sum(res)

if __name__ == '__main__':
    ans = main()
    print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:


#gcdは3.4.3だとfractionsにある
from fractions import gcd
import math

from math import factorial as f

from math import ceil,floor,sqrt


import bisect
import re
import heapq


from copy import deepcopy
import itertools

from sys import exit

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


def main():
    n,k = mi()
    a = li()
    a = list(reversed(sorted(a)))
    ans = 0
    for i in range(k,n):
        ans+=a[i]
    print(ans)



main()

Submission status: Accepted

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

H.sort(reverse=True)

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

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

H.sort()
H.reverse()

print(sum(H[K:]))

Submission status: Accepted

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

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

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(min(k, len(h))):
    h[i] = 0
print(sum(h))

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def main():
    n,k=MI()
    hh=LI()
    hh.sort()
    if k>=n:
        print(0)
        exit()
    if k==0:
        print(sum(hh))
        exit()
    print(sum(hh[:-k]))

main()

Submission status: Accepted

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


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


def read_list():
    return list(read_values())


def read_lists(N):
    return [read_list() for n in range(N)]


def main():
    N, K = read_values()
    H = read_list()
    H.sort(reverse=True)
    print(sum(H[min(N, K):]))


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

ans = sum(H) - sum(H[:K])
print(ans)

Submission status: Accepted

Solution code:
def main():
    import sys
    input = sys.stdin.readline

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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    N, K = (int(i) for i in input().split())
    H = [int(i) for i in input().split()]
    ans = 0
    H.sort(reverse=True)
    if N <= K:
        return print(ans)
    for h in H[K:]:
        ans += h
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:

a,b = map(int,input().split())
l = list(map(int,input().split()))
l.sort()
if b >= a:
    print(0)
    exit()
ans = 0
for i in range(a-b):
    ans += l[i]

print(ans)