starttime=[10, 30]
endtime=[14, 50]
N=3
info=[[1, 10, 19], [2, 8, 20], [3, 21, 3]]
starttime=starttime[0]*60+starttime[1]
endtime=endtime[0]*60+endtime[1]
info_table=[]
for i in range(N):
ID=info[i][0]
dist=info[i][1]
people=info[i][2]
costtime=dist*10
arrivetime=starttime+costtime
if arrivetime<8*60 :
costtime+=480-arrivetime
elif arrivetime<10*60:
costtime+=max(0,people+(arrivetime-480)*3-(arrivetime-480))
elif arrivetime<12*60:
costtime+=max(0,people+(600-480)*3-(arrivetime-480))
elif arrivetime<14*60:
costtime+=max(0,people+(arrivetime-720)*10+(600-480)*3-(arrivetime-480))
elif arrivetime<20*60:
costtime+=max(0,people+(840-720)*10+(600-480)*3-(arrivetime-480))
costmoney=dist*10
info_table.append([ID,costtime,costmoney])
info_table=sorted(info_table,key=lambda x:(x[1],x[2],x[0]))
res=[]
count=0
for i in range(len(info_table)):
if info_table[i][1]+starttime<20*60:
count+=1
res.append([str(x) for x in info_table[i]])
print(count)
for i in range(len(res)):
print(' '.join(res[i]))