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: Runtime Error

Solution code:
i=list(map(int,input().split()))
j=list(map(int,input().split()))
c=0
j.sort(reverse=True)
for x in range(i[1]):
  del j[0]
for y in j:
  c+=y
print(str(c))

Submission status: Runtime Error

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

Submission status: Runtime Error

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

if(K==len(H)):
  print(0)
else:
  temp = sorted(H)
  while K>0:
    temp=temp[:-1]
    K-=1
  for i in temp:
    total+=i
  print(total)

Submission status: Runtime Error

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

for i in range(K):
	H.pop((N-1)-i)

#print(H)

print(sum(H))

Submission status: Runtime Error

Solution code:
monster, skill = map(int,input().split())

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

monster_hp.sort()

attack_count = 0

while(skill>0):
    skill -= 1
    monster_hp.pop(-1)

for hp in monster_hp:
    attack_count += hp

print(attack_count)

Submission status: Runtime Error

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

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

Submission status: Runtime Error

Solution code:
import math
N,K = map(int,(input().split()))
L = list(map(int,(input().split())))
L.sort()
print(L)
for x in range(K):
    del L[-1]
print(sum(L))

Submission status: Runtime Error

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

if k > n:
    print(0)
else:
    for i in range(k):
        h.pop(i)
        
    print(sum(h))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
a,b=map(int,input().split())
h=list(map(int,input().split()))
ha=sorted(h,reverse=True)
for i in range(b):
  ha[i]=0
j=0
for t in ha:
  j+=t
print(t)

Submission status: Runtime Error

Solution code:
from heapq import heapify, heappop
from math import ceil
N, K = map(int, input().split())
H = list(map(int, input().split()))
Hminus = list(map(lambda x: x*(-1), H))
Hheap = heapify(Hminus)
for _ in range(K):
    heappop(Hheap)
print(sum(Hheap))

Submission status: Runtime Error

Solution code:
n,k = map(int,input().split())
l = [int(i) for i in input().split()]
for i in range(k):
    l.remove(max(l))
print(sum(l))

Submission status: Runtime Error

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

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

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

if len(H) > 0:
    print(sum(H))
else:
    print("0")

Submission status: Runtime Error

Solution code:
monster, skill = map(int,input().split())

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

monster_hp.sort()

attack_count = 0

while(skill>0):
    skill -= 1
    monster_hp.pop(-1)

for hp in monster_hp:
    attack_count += hp

print(hp)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

if N<=K:
  print(0)
else:
  for i in range(K):
    maxh=max(H)
    H=H.remove(maxh)
  print(len(H))

Submission status: Runtime Error

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


print(sum(h))

Submission status: Runtime Error

Solution code:
monster, skill = map(int,input().split())

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

sorted_monster_hp = monster_hp.sort()

attack_count = 0

while(skill>0):
    skill -= 1
    sorted_monster_hp.pop(-1)

for hp in sorted_monster_hp:
    attack_count += hp

print(hp)

Submission status: Runtime Error

Solution code:
a,b = map(int,input().split())
N = list(map(int,input().split()))
N.sort()
for i in range(b):
    N.pop()
print(sum(N))

Submission status: Runtime Error

Solution code:
N, K = map(int, input().split())
H = sorted([int(x) for x in input().split()], inverse=True)
if K >= len(H):
    print('0')
else:
    print(sum(H[K:]))

Submission status: Runtime Error

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

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

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

print(sum(H))

Submission status: Runtime Error

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

if n < k:
  print(0)
else:
   for i in range(0, k):
    h[n-i-1] = 0
  
   for i in range(0, n):
    sum += h[i]
  print(sum)

Submission status: Runtime Error

Solution code:
n,k=map(int,input().split())
h=list(map(int,input().split()))
h.sort()
for i in range(k):
    h.pop()
print(sum(h))

Submission status: Runtime Error

Solution code:
N,K = map(int,input().split())
W = sorted(list(map(int,input().split())),reverse=True)
if N<=K:
    print(0)
for i in range(K):
    W[i] = 0
print(sum(W))

Submission status: Runtime Error

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

Submission status: Runtime Error

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

if N<=K:
  print(0)
else:
  for i in range(K):
    maxh=max(H)
    H=H.remove(maxh)
  print(len(H))

Submission status: Runtime Error

Solution code:
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")

#include "bits/stdc++.h"
using namespace std;

#define pb push_back
#define F first
#define S second
#define f(i,a,b)  for(int i = a; i < b; i++)
#define endl '\n'

using ll = long long;
using db = long double;
using ii = pair<int, int>;

const int N = 1e5 + 5, LG = 19, MOD = 1e9 + 7;
const int SQ =225;
const long double EPS = 1e-7;

int32_t main(){
#ifdef ONLINE_JUDGE
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#endif

    int n, k;
    cin >> n >> k;
    vector<int>a(n);
    for(auto & x : a)cin >> x;
    sort(a.begin(),a.end());
    a.resize(n-k);
    cout << accumulate(a.begin(),a.end(),0ll) << '\n';


  return 0;
}

Submission status: Runtime Error

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

h = list(map(int, inoput().split))
sum = 0
h.sort()

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

Submission status: Runtime Error

Solution code:
a, b = map(int, input().split())
l = [int(x) for x in input().split()]

l.sort()
i = a - 1

for x in range(b):
    l[i] = 0
    i -= 1

print(sum(l))

Submission status: Runtime Error

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


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

Submission status: Runtime Error

Solution code:
#include <algorithm>
#include <array>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <string>
#include <utility>
#include <vector>

#define rep(i, n) for (int i = 0; i < (int)(n); i++)

using namespace std;

int main() {
  int N, K;
  cin >> N >>  K;

  vector<int> H(N);
  rep(i, N)
    cin >> H[i];
  
  long long ret=0;
  sort(H.begin(), H.end());
  rep(i, N-K) {
    ret+=H[i];
  }
  cout << ret << endl;

  return 0;
}

Submission status: Runtime Error

Solution code:
h, k = map(int, input().split())
lis = list(map(int, input().split()))
for i in range(k):
    lis.remove(max(lis))
    
print(sum(lis))

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n,k=map(int,input().split())
h=list(map(int,input().split()))
h.append(0)
h.sort()
for i in range(k):
  h.pop(-1)
print(sum(h))