k, n1 = [int(x) for x in input().split()]
meeting_counts = [n1]
continuations = [[]]
for i in range(k - 1):
day = [int(x) for x in input().split()]
meeting_counts.append(day[0])
continuations.append(day[1:])
most = meeting_counts[-1]
to_attend = [1] * meeting_counts[-1]
for day in range(k - 1, 0, -1):
new_to_attend = [0] * meeting_counts[day - 1]
for meeting in range(meeting_counts[day]):
if continuations[day][meeting] != 0:
required = continuations[day][meeting] - 1
new_to_attend[required] += to_attend[meeting]
for i in range(len(new_to_attend)):
new_to_attend[i] = max(1, new_to_attend[i])
most = max(most, sum(new_to_attend))
to_attend = new_to_attend
print(most)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | k, n1 = [int(x) for x in input().split()] meeting_counts = [n1] continuations = [[]] for i in range(k - 1): day = [int(x) for x in input().split()] meeting_counts.append(day[0]) continuations.append(day[1:]) most = meeting_counts[-1] to_attend = [1] * meeting_counts[-1] for day in range(k - 1, 0, -1): new_to_attend = [0] * meeting_counts[day - 1] for meeting in range(meeting_counts[day]): if continuations[day][meeting] != 0: required = continuations[day][meeting] - 1 new_to_attend[required] += to_attend[meeting] for i in range(len(new_to_attend)): new_to_attend[i] = max(1, new_to_attend[i]) most = max(most, sum(new_to_attend)) to_attend = new_to_attend print(most) |
English