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: Time Limit Exceeded

Solution code:
n, k=map(int, input().split())
h=list(map(int, input().split()))
while k>0 and n>0:
    h.remove(max(h))
    k -= 1
    n -= 1
print(sum(h))

Submission status: Time Limit Exceeded

Solution code:
N,K = map(int,input().split())
L = list(map(int,input().split()))
L.sort()
L.reverse()
count = K
ans = 0
for i in range(len(L)):
  if count != 0:
    L[i] = 0
    ans += 1
    count -= 1
    if sum(L) == 0:
      count = 0
      break
  else:
    break
print(count+sum(L))

Submission status: Time Limit Exceeded

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:
      	# ここを追加
        for i in range(K):
            H.remove(max(H))
        print(sum(int(i) for i in H))

Submission status: Time Limit Exceeded

Solution code:
a = list(map(int, input().split()))
b = list(map(int, input().split()))
y=(a[0] if a[1]>=a[0] else a[1])
for i in range(y):
    b.remove(max(b))
print(sum(b))

Submission status: Time Limit Exceeded

Solution code:
a = list(map(int, input().split()))
b = list(map(int, input().split()))
b.sort()  
b.reverse()
if a[1]>=a[0]:
    y=a[0]
else:
    y=a[1]
for i in range(y):
    del b[0]
print(sum(b))

Submission status: Time Limit Exceeded

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

input_hp = input().split()

list_monster = []
for i in range(n):
  list_monster.append(int(input_hp[i]))
  
list_monster.sort() 
list_monster.reverse() #降順にソート

#使用できる必殺技の残りカウント
count = k 
  
if n <= k:
  print(0)
  
elif k == 0:
  number = 0
  for i in range(len(list_monster)):
    number += list_monster[i]
  
  print(number)
  
else:
  for i in range(k): #最初に持っていた必殺技の数だけ繰り返す
    count -= 1 #使用ごとに必殺技の残りカウントを減らす
    
    list_monster.pop(0)
    
  number = 0

  for i in range(len(list_monster)):
  	number += list_monster[i]

  print(number)

Submission status: Time Limit Exceeded

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

# スペース区切りの整数の入力
b, c = map(int, input().split())
# 空白区切り入力 List
s = input().split()

s_list = []
s_list = [int(s) for s in s]
list.sort(s_list, reverse=True)

num = 0
sum = 0
if(c < len(s_list)):
	for num in range(c):
		#print(num)
		#print(s_list)
		s_list.pop(0)
	for inp in s_list:
		sum = sum + int(inp)
print(sum)

Submission status: Time Limit Exceeded

Solution code:
N, K = input().split()
this_list = [int(x) for x in input().split()]
final_list =[]
if(len(this_list) < int(K)):
    K = len(this_list)
for i in range(int(K)):
    max1 = 0
    for j in range(len(this_list)):
        if(this_list[j])>max1:
            max1 = this_list[j]
    this_list.remove(max1)
    final_list.append(max1)

print(sum(this_list))

Submission status: Time Limit Exceeded

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

input_hp = input().split()

list_monster = []
for i in range(n):
  list_monster.append(int(input_hp[i]))
  
list_monster.sort() 
list_monster.reverse() #降順にソート

#使用できる必殺技の残りカウント
count = k 
  
if n <= k:
  print(0)
else:
  for i in range(k): #最初に持っていた必殺技の数だけ繰り返す
    count -= 1 #使用ごとに必殺技の残りカウントを減らす
    
    list_monster.pop(0)
    
  number = 0

  for i in range(len(list_monster)):
  	number += list_monster[i]

  print(number)

Submission status: Time Limit Exceeded

Solution code:
attack = [int(x) for x in raw_input().split()]
monster = list(map(int,raw_input().split()))
mon = attack[0]
if (mon <= attack[1]):
  print(0)
else:
  for i in range(0,attack[1]):
    monster.remove(max(monster))
    mon = mon - 1
    if(mon == 0): break
  print(sum(monster))

Submission status: Time Limit Exceeded

Solution code:
attack = [int(x) for x in raw_input().split()]
monster = [int(x) for x in raw_input().split()]
mon = attack[0]
if (mon <= attack[1]):
  print(0)
else:
  for i in range(0,attack[1]):
    monster.remove(max(monster))
    mon = mon - 1
    if(mon == 0): break
  print(sum(monster))

Submission status: Time Limit Exceeded

Solution code:
N, K = map(int, input().split())
H = [int(N) for N in input().split()]
for i in range(0, K):
    if H[H.index(max(H))] == 0:
        break
    H[H.index(max(H))] = 0
print(sum(filter(lambda x: x != 0, H)))

Submission status: Time Limit Exceeded

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]#必殺技の回数
    # c = sum(t)
    # d = int(s[1])
    # for i in range(int(s[1])):
    #     if sum(t) != 0:
    #         if d != 0:
    #             c -= max(t)
    #             for j in range(int(s[0])):
    #                 if max(t) == t[j]:
    #                     t[j] = 0
    #             d -= 1
    #         else:
    #             break
    e = 0  #Max
    f = 0# Maxのいち
    for j in range(d):  #必殺技の回数
        c = sum(t)
        if c != 0:
            for i in range(b):
                if e < t[i]:
                    e = t[i]
                    f = i
            t[f] = 0
            e = 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: Time Limit Exceeded

Solution code:
import os
import sys
import heapq

def main():
    H , K = map(int , input().split())
    n_list = [s for s in input().split()]
    n_list = list(map(int,n_list))
    #print (n_list)
    #c = sum(int(i) for i in list)
    list_small = []
    new_list = []
    if K >= len(n_list) :
        print (str(0))
    elif K == 0 :
        c = sum(int(i) for i in n_list)
        print (str(c))
    else :
        list_small = heapq.nlargest(K,n_list)
        list_small = list(map(int,list_small))
        #print (list_small)
        #new_list = list(set(n_list)-set(list_small))
        new_list = list_difference(n_list, list_small)
        #print (list_small)
        #print (new_list)
        c = sum(int(i) for i in new_list)
        print (str(c))
    #print (str(X))
def list_difference(list1, list2):
    result = list1.copy()
    for value in list2:
        if value in result:
            result.remove(value)

    return result

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
attack = raw_input().split()
monster = [int(x) for x in raw_input().split()] 
spec = int(attack[1])
for i in range(0,spec):
  if(len(monster)<=0):
    break
  monster.remove(max(monster))
print(sum(monster))

Submission status: Time Limit Exceeded

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 = input().split()
    t = input().split()
    for i in range(int(s[0])):
        t[i] = int(t[i])
    a = 0  #勝つまでの回数
    # c = sum(t)
    # d = int(s[1])
    # for i in range(int(s[1])):
    #     if sum(t) != 0:
    #         if d != 0:
    #             c -= max(t)
    #             for j in range(int(s[0])):
    #                 if max(t) == t[j]:
    #                     t[j] = 0
    #             d -= 1
    #         else:
    #             break
    e = 0  #Max
    f = 0# Maxのいち
    for j in range(int(s[1])):  #必殺技の回数
        c = sum(t)
        if c != 0:
            for i in range(int(s[0])):
                if e < t[i]:
                    e = t[i]
                    f = i
            t[f] = 0
            e = 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: Time Limit Exceeded

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

H_sorted = sorted(H, reverse=True)

for _ in range(K):
    if (not len(H_sorted)):
        break
    H_sorted.pop(0)

print(sum(H_sorted))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

input_line = list(map(int,input().split()))
input_hp = list(map(int,input().split()))
try:
    [(input_hp.sort(reverse=True) ,input_hp.pop(_)) for _ in range(input_line[1])]
    print(sum(input_hp))
except IndexError:
    print('0')

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8
bodies_count = list(map(int,input().split()))
enemy_life = list(map(int,input().split()))
count = 0

if bodies_count[1] == 0:
    print(sum(enemy_life))
else:
    for i in range(bodies_count[1]):
        if enemy_life == []:
            print(count)
            break
        else:
            enemy_life.pop(enemy_life.index(max(enemy_life)))

    if enemy_life != []:
        print(sum(enemy_life))

Submission status: Time Limit Exceeded

Solution code:
attack = raw_input().split()
monster = raw_input().split()
monster = [int(x) for x in monster] 
for i in range(0,int(attack[1])):
  if(len(monster)>0):
    monster.remove(max(monster))
  else: break
print(sum(monster))

Submission status: Time Limit Exceeded

Solution code:
N, K = [int(i) for i in input().rstrip().split(' ')]
H = [int(i) for i in input().rstrip().split(' ')]
H.sort(reverse=True)
if len(H) <= K:print(0)
else:
    for hit in range(K):
        if len(H) == 0: break
        H.pop(0)
    print(sum(H))

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8
bodies_count = list(map(int,input().split()))
enemy_life = list(map(int,input().split()))
count = 0

if bodies_count[1] == 0:
    print(sum(enemy_life))
else:
    for i in range(bodies_count[1]):
        if enemy_life == []:
            print(count)
            break
        else:
            enemy_life.pop(enemy_life.index(max(enemy_life)))

    if enemy_life != []:
        total_life = sum(enemy_life)
        while total_life > 0:
            total_life -= 1
            count += 1
        print(count)

Submission status: Time Limit Exceeded

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

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) ,input_hp.pop(_)) for _ in range(input_line[1])]
    print(sum(input_hp))

Submission status: Time Limit Exceeded

Solution code:

N, K=map(int,input().split())
arr = list(map(int,input().split()))
if(K>= N):
  print('0')
else:
  if (K > 0):
    for i in range(K):
      arr.remove(max(arr))

  print(sum(arr))

Submission status: Time Limit Exceeded

Solution code:
n,k=input().split()
nn=int(n)
kk=int(k)
s=0
c=0

h = list(map(int, input().split()))
for i in h:
    s=s+i

if kk==0:
    print(s)
else:
    while kk>0:
        s=s-max(h)
        kk=kk-1
    if s<0:
        print(0)
    else:
        print(s)

Submission status: Time Limit Exceeded

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

if K > N: 
    print(0)
else:
    for i in range(K):
        health.pop(0)
    res = sum(health)
    print(res)

Submission status: Time Limit Exceeded

Solution code:

N, K=map(int,input().split())
arr = list(map(int,input().split()))
if(K>= N):
  print('0')
else:
  if (K > 0):
    while(K):
      arr.remove(max(arr))
      K -= 1;

  print(sum(arr))

Submission status: Time Limit Exceeded

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

h.sort(reverse=True)

for i in range(min(n,k)):
    h.pop(0)

print(sum(h))

Submission status: Time Limit Exceeded

Solution code:
N, K = map(int, input().split())
Health = map(int, input().split())
temp = sorted(Health, reverse=True)
if K >= N:
    print(0)
else:
    for i in range(K):
        temp.pop(0)
    print(sum(temp))

Submission status: Time Limit Exceeded

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

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) ,input_hp.pop(i)) for i in range(input_line[1])]
    print(sum(input_hp))

Submission status: Time Limit Exceeded

Solution code:
ipt=input().split()
num=int(ipt[0])
tech=int(ipt[1])
ipt=input().split()
monster=[]
for i in ipt:
  monster.append(int(i))
monster.sort()
monster.reverse()
total=0
for i in range(tech):
	if len(monster)>0:
		monster.pop(0)
for i in monster:
	total+=i
print(total)

Submission status: Time Limit Exceeded

Solution code:
N, K = map(int, input().split())
H = [int(N) for N in input().split()]
for i in range(0, K):
    H[H.index(max(H))] = 0
print(sum(filter(lambda x: x != 0, H)))

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

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

if N>K:
    for i in range(K):
        H.remove(np.max(H))
    print(sum(H))
else:
    print(0)

Submission status: Time Limit Exceeded

Solution code:
ipt=input().split()
num=int(ipt[0])
tech=int(ipt[1])
ipt=input().split()
monster=[]
for i in ipt:
  monster.append(int(i))
monster.sort()
monster.reverse()
total=0
if tech<num:
  for i in range(tech):
    monster.pop(0)
  total=0
  for i in monster:
    total+=i
print(total)

Submission status: Time Limit Exceeded

Solution code:
import numpy

N, K = map(int, input().split())
H = list(map(int, input().split()))
ans = 0
if N <= K:
    print(0)
else:
    num = N - K
    for r in range(num):
        min = numpy.min(H)
        H.remove(min)
        ans = ans + min
    print(ans)

Submission status: Time Limit Exceeded

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 = input().split()
    t = input().split()
    for i in range(int(s[0])):
        t[i] = int(t[i])
    a = 0  #勝つまでの回数
    c = sum(t)
    d = int(s[1])
    for i in range(int(s[1])):
        if sum(t) != 0:
            if d != 0:
                c -= max(t)
                for j in range(int(s[0])):
                    if max(t) == t[j]:
                        t[j] = 0
                d -= 1
            else:
                break
    
    print(a+sum(t))
    return 0

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

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

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

Submission status: Time Limit Exceeded

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) ,input_hp.pop(i)) for i in range(input_line[1])]
    print(sum(input_hp))

Submission status: Time Limit Exceeded

Solution code:
N,K=map(int,input().split())
H=list(map(int,input().split()))
t=list()
for i in range(N-K):
    t.append(sorted(H)[i])
print(sum(t))

Submission status: Time Limit Exceeded

Solution code:
import sys
NK = input().split()
N,K = int(NK[0]),int(NK[1])
H = list(map(int,input().split()))
if K != 0 and len(H) < K:
    print(0)
    exit()
for i in range(K):
    H.remove(max(H))
print(sum(H))

def input():
    return sys.stdin.readline()[:-1]

Submission status: Time Limit Exceeded

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

if len(x) < b:
    b = len(x)
for i in range(b):
    x[x.index(max(x))] = 0

print(sum(x))

Submission status: Time Limit Exceeded

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

def max_pop(ary):
  max = 0
  ind = 0
  for i,a in enumerate(ary):
    if max < a:
      max = a
      ind = i
  del ary[i]
  return ary

def sum_ary(ary):
  total = 0
  for a in ary:
    total += a
  return total

if n >= len(a):
  print(0)
  exit()
for _ in range(n):
  a = max_pop(a)
print(sum_ary(a))

Submission status: Time Limit Exceeded

Solution code:
# ABC 153 C

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

for _ in range(k):
    if len(H) != 0:
        H.remove(max(H))

print(sum(H))

Submission status: Time Limit Exceeded

Solution code:
import math
N,K = map(int,(input().split()))
L = list(map(int,(input().split())))
L.sort(reverse=True)
#print(L)
for x in range(K):
    #print(x)
    if (len(L) != 0):
        del L[0]
   # print(L)
print(sum(L))

Submission status: Time Limit Exceeded

Solution code:
N, K = map(int, input().split())
H_list = list(map(int, input().split()))
if N-K <= 0:
    print(0)
else:
    for _ in range(K):
        A = H_list.index(max(H_list))
        H_list[A] = 0
    print(sum(H_list))

Submission status: Time Limit Exceeded

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

for i in range(b):
    x[x.index(max(x))] = 0

print(sum(x))

Submission status: Time Limit Exceeded

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

def max_pop(ary):
  max = 0
  for a in ary:
    if max < a:
      max = a
  ary.remove(max)
  return ary

def sum_ary(ary):
  total = 0
  for a in ary:
    total += a
  return total

if n >= len(a):
  print(0)
  exit()
for _ in range(n):
  a = max_pop(a)
print(sum_ary(a))

Submission status: Time Limit Exceeded

Solution code:
N, K = map(int, input().split())
H = [int(N) for N in input().split()]
for i in range(0, K):
    max_index = H.index(max(H))
    H[max_index] = 0
print(sum(int(i) for i in H))

Submission status: Time Limit Exceeded

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

while K > count:
  count += 1
  try:
    monsters.pop(0)
  except IndexError:
    pass

print(sum(monsters))

Submission status: Time Limit Exceeded

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

cnt = 0
if K >= N:
    cnt = 0
elif 1 <= K < N:
    for i in range(K):
        H.remove(max(H))
    cnt = sum(H)

elif K == 0:
    cnt = sum(H)

print(cnt)

Submission status: Time Limit Exceeded

Solution code:
def sort(A):
        for i in range(0, len(A) - 1):
            modify_order(A, i)

def modify_order(A, i):
    for j in range(len(A) - 1, i, -1):
        if A[j - 1] > A[j]:
            A[j - 1], A[j] = A[j], A[j - 1]

N, K = map(int, input().split())
H = list(map(int, input().split()))
ans = 0
if N <= K:
    print(0)
else:
    sort(H)
    num = N - K
    for r in range(0,num):
        ans = ans + H[r]
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
n, k=map(int, input().split())
h = [int(h) for h in input().split()] 
while k>0 and n>0:
    h.remove(max(h))
    k -= 1
    n -= 1
r=0
for i in h:
    r += i
print(r)

Submission status: Time Limit Exceeded

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 = input().split()
    t = input().split()
    for i in range(int(s[0])):
        t[i] = int(t[i])
    a = 0  #勝つまでの回数
    c = sum(t)
    d = int(s[1])
    for i in range(int(s[1])):
        if sum(t) != 0:
            if d != 0:
                c -= max(t)
                for j in range(int(s[0])):
                    if max(t) == t[j]:
                        t[j] = 0
                d -= 1
            else:
                t[i] -= 1
                a += 1
    print(a+sum(t))
    return 0

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

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

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

Submission status: Time Limit Exceeded

Solution code:
def testA(n):
    max_num = 0
    for i in n:
        if max_num < i:
            max_num = i
    return max_num
monster, hisatu = map(int, input().split())
m_life = list(map(int, input().split()))
count = 0
if hisatu >= len(m_life):
    print(0)
else:
    while hisatu > 0:
        m_life.remove(testA(m_life))
        hisatu -= 1
    for i in m_life:
        count += i
    print(count)

Submission status: Time Limit Exceeded

Solution code:
import sys
NK = input().split()
N,K = int(NK[0]),int(NK[1])
N = list(map(int,input().split()))
if K != 0 and len(N) < K:
    print(0)
    exit()
for i in range(K):
    N.remove(max(N))
print(sum(N))

def input():
    return sys.stdin.readline()[:-1]

Submission status: Time Limit Exceeded

Solution code:
N,K = map(int,input().split())
H = [int(x) for x in input().split()]
ld = sorted(H,reverse=True)
for _ in range(K):
    ld[0:1] = []
print(sum(ld))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

H_sorted = sorted(H, reverse=True)


for i in range(K):
	if len(H_sorted) == 0:
		break
	del H_sorted[0]

print(sum(H_sorted))

Submission status: Time Limit Exceeded

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

while (K > 0):
  del H[0]
  K -=1
  if len(H) == 0:
    break

print(sum(H))

Submission status: Time Limit Exceeded

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

# print(H)
H = sorted(H, reverse=True)
# print(H)

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

# print(H)

result = 0
for h in H:
    result += h
    
print(result)

Submission status: Time Limit Exceeded

Solution code:
N,K=map(int,input().split())
H=list(map(int,input().split()))
if K >= N:
    print(0)
else:
    for _ in range(K):
        H.pop(H.index(max(H)))
    print(sum(H))

Submission status: Time Limit Exceeded

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) for i in range(input_line[1])]
    [input_hp.pop(i) for i in range(input_line[1])]
    print(sum(input_hp))

Submission status: Time Limit Exceeded

Solution code:
N, K = map(int, input().lower().split())
H = []
total = 0
input_string = input()
H = input_string.split()
H = list(map(int, H))
for j in range(K):
    if not H:
        break
    else:
        H.remove(max(H))
print(sum(H))

Submission status: Time Limit Exceeded

Solution code:
x = input().split()
N = int(x[0])
K = int(x[1])
H = input().split()
H = [int(l) for l in H]

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

Submission status: Time Limit Exceeded

Solution code:


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

    sort_H = sorted(H, reverse=True)
    count = 0
    top = K
    if K >= N:
        print(0)
    elif K == 0:
        print(sum(H))
    else:
        while True:
            flag = True
            while flag:
                sort_H[top] -= 1
                count += 1
                if sort_H[top]==0:
                    flag=False
                    top += 1
                    break
            if top == N:break
        print(count)


if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

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

h = list(h)
max_monster = []

if k >= len(h):
  print("0")
else:
  for i in range(0, len(h)):
      h[i] = int(h[i])
      
  for i in range(0, k):
    max_monster.append(max(h))
  print(sum(h) - sum(max_monster))

Submission status: Time Limit Exceeded

Solution code:
monster, hisatu = map(int, input().split())
m_life = list(map(int, input().split()))
count = 0
if hisatu >= len(m_life):
    print(0)
else:
    while hisatu > 0:
        m_life.remove(max(m_life))
        hisatu -= 1
    for i in m_life:
        count += i
    print(count)

Submission status: Time Limit Exceeded

Solution code:
NK=input().split()
N=int(NK[0])
K=int(NK[1])
Hlis=list(map(int,input().split()))
ans=0

if K>=N:
    print(0)
else:
    for i in range(N-K):
        mini=Hlis.index(min(Hlis))
        ans+=Hlis[mini]
        Hlis.pop(mini)
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
NK = input().split()
N,K = int(NK[0]),int(NK[1])
N = list(map(int,input().split()))
if K != 0 and len(N) < K:
    print(0)
    exit()
for i in range(K):
    N.remove(max(N))
print(sum(N))

Submission status: Time Limit Exceeded

Solution code:
monster, hisatu = map(int, input().split())
m_life = list(map(int, input().split()))
count = 0
if hisatu >= len(m_life):
    print(0)
else:
    for i in range(hisatu):
        m_life.remove(max(m_life))
    for i in m_life:
        count += i
    print(count)

Submission status: Time Limit Exceeded

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

for i in range(k):
	try:
		h.remove(max(h))
	except ValueError as e:
		pass
print(sum(h))

Submission status: Time Limit Exceeded

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

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

sum=0

if K!=0:
	for A in range(K):
  		ln[ln.index(max(ln))]=0

for A in ln:
  sum+=A

print(sum)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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


H.sort(reverse=True)

while K > 0 and len(H) > 0:
    H.pop(0)
    K -= 1

i += sum(H)

print(i)

Submission status: Time Limit Exceeded

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

H = sorted(H, reverse=True)

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

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

Submission status: Time Limit Exceeded

Solution code:
n, k=map(int, input().split())
h=list(map(int, input().split()))
while k>0 and n>0:
    h.remove(max(h))
    k -= 1
    n -= 1
r=0
for i in h:
    r += i
print(r)

Submission status: Time Limit Exceeded

Solution code:
a=[int(i) for i in input().split()]
b=[int(i) for i in input().split()]
if a[1]>=a[0]:
    print(0)
else:
    c=[]
    if a[0]<=a[1]*2:
        for i in range(a[0]-a[1]):
            c.append(min(b))
            b.remove(min(b))
        print(sum(c))
    else:
        for i in range(a[1]):
            b.remove(max(b))
        print(sum(b))

Submission status: Time Limit Exceeded

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

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

sum=0

for A in range(K):
  ln[ln.index(max(ln))]=0

for A in ln:
  sum+=A

print(sum)

Submission status: Time Limit Exceeded

Solution code:
n ,k = map(int,input().split())
h = list(map(int,input().split()))
flag = 0
ans = 0
for i in range(k):
  if n <= k:
    break
  re = max(h)
  h.remove(re)
  flag += 1
for i in range(n - flag):
  if n <= k:
    ans = 0
  else:
    ans += h[i]
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import sys
a = input().split()  
b= input().split()
bb = [int(s) for s in b]
if int(a[1])>=int(a[0]):
 print("0")
 sys.exit()
else:
 for _ in range(0,int(a[1])):
  try:
   bb.remove(max(bb))
  except:
   print("0")
   sys.exit()
print(sum(bb))

Submission status: Time Limit Exceeded

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

h = list(h)

if k >= len(h):
  print("0")
else:
  for i in range(0, len(h)):
      h[i] = int(h[i])
      
  for i in range(0, k):
    h.remove(max(h))
  print(sum(h))

Submission status: Time Limit Exceeded

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:
    for i in range(input_line[1]):
        input_hp.sort(reverse=True)
        input_hp.pop(i)
    result = sum(input_hp)
    print(result)

Submission status: Time Limit Exceeded

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

for i in range(b):
    x[x.index(max(x))] = 0

print(sum(x))

Submission status: Time Limit Exceeded

Solution code:
N,K = map(int,input().split())
N = list(map(int,input().split()))
if K != 0 and len(N) < K:
    print(0)
    exit()
for i in range(K):
    N.remove(max(N))
print(sum(N))

Submission status: Time Limit Exceeded

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

for i in range(k):
    m = li.index(max(li))
    li[m] = 0

print(sum(li))