@@ -0,0 +1,1171 @@
+# http://www.prologin.org/training/challenge/demi2014/deadline%0Afrom sys import stdin%0Afrom itertools import combinations%0A%0AremainingTime = int(stdin.readline())%0AremainingExercises = int(stdin.readline())%0A%0A# Grab exercises%0Adata = %5B%5D%0Afor i in range(remainingExercises):%0A%09data.append(%5Bint(x) for x in stdin.readline().split()%5D)%0A%0AhasSolution = True%0AcombinationLength = 2%0AmaxPoints = 0%0A%0Awhile hasSolution:%0A%09attemptsInRange = %5B%5D%0A%0A%09# Get every combination having a length %22combinationLength%22%0A%09for attempt in combinations(data, combinationLength):%0A%09%09timer = 0%0A%09%09points = 0%0A%09%09# Transform tuples to a list%0A%09%09attempt = list(attempt)%0A%0A%09%09for exercise in attempt:%0A%09%09%09timer += exercise%5B0%5D%0A%09%09%09points += exercise%5B1%5D%0A%0A%09%09# Remember if the attemp was in our allowed time range%0A%09%09inTimeAllowed = (timer %3C= remainingTime)%0A%09%09attemptsInRange.append(inTimeAllowed)%0A%0A%09%09# We have found a solution! Remember it%0A%09%09if (inTimeAllowed and points %3E maxPoints):%0A%09%09%09maxPoints = points%0A%0A%09# If we had only failed attemps, we can't do better%0A%09if (attemptsInRange.count(False) == len(attemptsInRange)):%0A%09%09hasSolution = False%0A%09# Otherwise, try to do more exercises%0A%09else:%0A%09%09combinationLength += 1%0A%0Aprint maxPoints

Add exercise 12: deadline