CollegeRank1 Question B :
Code :
import operator
def allocate(clg):
flag = 0
for x in clg:
for y in range(len(seats)):
if seats[int(x[2:])-1] != 0:
seats[int(x[2:])-1] -= 1
flag = 1
break
if flag == 1:
return [True,x]
return [False]
C, N = list(map(int, input().split()))
seats = list(map(int,input().split()))
students = []
output = []
for x in range(N):
students.append(input().split(','))
students = sorted(students, key=operator.itemgetter(1), reverse=True)
for x in students:
val = allocate(x[2:])
if val[0]:
print(x[0],val[1])
# 3 5
# 3 1 2
# Student-1,97.05,C-1,C-3,C-2
# Student-2,48.03,C-1,C-2,C-3
# Student-3,85.69,C-1,C-3,C-2
# Student-4,80.83,C-1,C-3,C-2
# Student-5,41.23,C-1,C-2,C-3
# 4 5
# 2 1 1 1
# Student-1,97.05,C-1,C-3,C-2
# Student-2,48.03,C-1,C-2,C-3
# Student-3,85.69,C-1,C-3,C-2
# Student-4,80.83,C-1,C-3,C-2
# Student-5,41.23,C-1,C-2,C-34 5
Question :