Last active
March 24, 2019 18:48
-
-
Save kagan94/2d766a83edd677dc4746ae55e42391d7 to your computer and use it in GitHub Desktop.
Kick Start 2019 (Round A, problem #1)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def solve(students_needed, skills): | |
skills.sort() | |
min_hours = float('+inf') | |
for i in range(0, len(skills) - students_needed + 1): | |
_range = skills[i: i + students_needed] | |
hours_needed = (max(_range) * students_needed) - sum(_range) | |
if min_hours > hours_needed: | |
min_hours = hours_needed | |
return min_hours | |
def main(): | |
T = int(input()) | |
for case_n in range(1, T + 1): | |
N, P = map(int, raw_input().split(' ')) | |
Si = map(int, raw_input().split(' ')) | |
result = solve(P, Si) | |
print 'Case %s: %s' % (case_n, result) | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment