LoginSignup
0
0

More than 3 years have passed since last update.

PythonでABC160-Eを解く

Last updated at Posted at 2020-05-07

はじめに

緑diffを解けるようになりたいので、解けそうな緑diffを解きます。

Red and Green Apples

赤のリンゴは最大でも$X$個、緑のリンゴは最大でも$Y$個しか食べないので、$p,q$を降順で並べたときの前から$X,Y$個しか食べません。無色のリンゴは両方の色にできるので$p[:X],q[:Y],r$を連結して降順で並べます。その連結したリストの前から$X+Y$までの合計が答えになります。
また、Pythonのlistに対するsortは$O(N log N)$なので耐えます。

x, y, a, b, c = map(int,input().split())
p = list(map(int,input().split()))
q = list(map(int,input().split()))
r = list(map(int,input().split()))

p.sort(reverse=True)
q.sort(reverse=True)
p = p[:x]
q = q[:y]
apple = p + q + r
apple.sort(reverse=True)
ans = sum(apple[:x+y])
print(ans)

まとめ

緑になりたい。ではまた。

0
0
2

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