File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ def solution ():
2+ number = int (input ())
3+
4+ min_constructor = number
5+ for candidate_constructor in range (number )[::- 1 ]:
6+ result = candidate_constructor + sum (int (digit ) for digit in str (candidate_constructor ))
7+ if result == number :
8+ min_constructor = candidate_constructor
9+
10+ if min_constructor == number :
11+ return 0
12+
13+ return min_constructor
14+
15+
16+ if __name__ == "__main__" :
17+ print (solution ())
Original file line number Diff line number Diff line change 1+ from itertools import combinations
2+
3+
4+ def solution ():
5+ _ , dealer_card_number = map (int , input ().split ())
6+ my_card_numbers = [int (number ) for number in input ().split ()]
7+
8+ approximate_value = 0
9+ for case in combinations (my_card_numbers , 3 ):
10+ sum_of_card_numbers = sum (case )
11+ if sum_of_card_numbers > dealer_card_number :
12+ continue
13+
14+ if sum_of_card_numbers > approximate_value :
15+ approximate_value = sum_of_card_numbers
16+
17+ return approximate_value
18+
19+
20+ if __name__ == "__main__" :
21+ print (solution ())
Original file line number Diff line number Diff line change 1+ def solution ():
2+ cases_count = int (input ())
3+ people_size_info_list = [list (map (int , input ().split ())) for _ in range (cases_count )]
4+
5+ ranking_table = {}
6+ for index , people_size_info in enumerate (people_size_info_list ):
7+ ranking_table [index ] = 1
8+ weight , height = people_size_info
9+ for target_people_size_info in people_size_info_list :
10+ target_weight , target_height = target_people_size_info
11+ if target_weight > weight and target_height > height :
12+ ranking_table [index ] += 1
13+ return " " .join (str (rank ) for rank in ranking_table .values ())
14+
15+
16+ if __name__ == "__main__" :
17+ print (solution ())
You can’t perform that action at this time.
0 commit comments