LoginSignup
0
0

More than 1 year has passed since last update.

ABC153 C - Fennec vs Monster を解いた

Last updated at Posted at 2021-10-14

abc153c_1.png
abc153c_2.png
abc153c_3.png

たぶん、やり方は色々あると思う。

abc153c_r1.py
N,K = map(int,input().split())
H = list(map(int,input().split()))
H.sort(reverse=True)
#print(H)

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

print(sum(H))#117ms

極力シンプルに書くとスピードが上がるようだ。

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

H.sort()

if K > N:
    print(0)
else:
    print(sum(H[:N-K]))#105ms
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0