3
3
# pylint: enable=line-too-long
4
4
5
5
# pylint: disable=too-few-public-methods
6
- class Competition :
6
+ class Contest :
7
7
luck = 0
8
8
important = 0
9
9
@@ -17,33 +17,33 @@ def __getitem__(self, item):
17
17
18
18
def luck_balance (k , contests : list ) -> int :
19
19
20
- important_competitions : list [Competition ] = []
21
- nonimportant_competitions : list [Competition ] = []
20
+ important_contests : list [Contest ] = []
21
+ nonimportant_contests : list [Contest ] = []
22
22
23
23
for contest in contests :
24
24
luck = contest [0 ]
25
25
important = contest [1 ]
26
26
27
27
if important == 1 :
28
- important_competitions .append (Competition (luck = luck , important = important ))
28
+ important_contests .append (Contest (luck = luck , important = important ))
29
29
else :
30
- nonimportant_competitions .append (Competition (luck = luck , important = important ))
30
+ nonimportant_contests .append (Contest (luck = luck , important = important ))
31
31
32
- important_competitions = sorted (
33
- important_competitions ,
32
+ important_contests = sorted (
33
+ important_contests ,
34
34
key = lambda contest : (- contest ['important' ], - contest ['luck' ])
35
35
)
36
36
37
37
total : int = 0
38
- size : int = len (important_competitions )
38
+ size : int = len (important_contests )
39
39
40
40
for i in range (0 , min (k , size )):
41
- total += important_competitions [i ].luck
41
+ total += important_contests [i ].luck
42
42
43
43
for i in range (min (k , size ), size ):
44
- total -= important_competitions [i ].luck
44
+ total -= important_contests [i ].luck
45
45
46
- for x in nonimportant_competitions :
47
- total += x .luck
46
+ for contest in nonimportant_contests :
47
+ total += contest .luck
48
48
49
49
return total
0 commit comments