-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtask_1626.py
More file actions
29 lines (22 loc) · 888 Bytes
/
task_1626.py
File metadata and controls
29 lines (22 loc) · 888 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
from typing import List
class Solution:
def bestTeamScore(self, scores: List[int], ages: List[int]) -> int:
players = []
n = len(ages)
for i in range(n):
players.append([ages[i], scores[i]])
players.sort()
# print(players)
dp = n * [0]
ans = 0
for i in range(n):
dp[i] = players[i][1]
for j in range(i):
if players[i][0] >= players[j][0] and players[i][1] >= players[j][1]:
dp[i] = max(dp[i], dp[j] + players[i][1])
ans = max(ans, dp[i])
# print(dp)
return ans
print(Solution().bestTeamScore(scores = [1,3,5,10,15], ages = [1,2,3,4,5]))
print(Solution().bestTeamScore(scores = [4,5,6,5], ages = [2,1,2,1]))
print(Solution().bestTeamScore(scores = [1,2,3,5], ages = [8,9,10,1]))