module suimin TYPE time integer::H integer::M end type time TYPE sleep type(time)::shuusin type(time)::kishou integer::sleep_time end type sleep contains integer function kaiseki(s,str,N) implicit none character*16,allocatable::str(:,:) type(sleep),allocatable::s(:) integer::colon1,colon2,N,i,total=0 do i=1,N colon1 = INDEX(str(1,i),':') colon2 = INDEX(str(2,i),':') read(str(1,i)(1:colon1-1),*) s(i)%shuusin%H read(str(1,i)(colon1+1:LEN_TRIM(str(1,i))),*) s(i)%shuusin%M read(str(2,i)(1:colon2-1),*) s(i)%kishou%H read(str(2,i)(colon2+1:LEN_TRIM(str(2,i))),*) s(i)%kishou%M s(i)%sleep_time = MOD(((s(i)%kishou%H +24)*60 + s(i)%kishou%M) & - ((s(i)%shuusin%H )*60 + s(i)%shuusin%M), 60*24) total = total + s(i)%sleep_time end do kaiseki = total end function kaiseki end module suimin program main use suimin integer::N character*16,allocatable::str(:,:) type(sleep),allocatable::s(:) read *,N allocate(str(2,N)) allocate(s(N)) read *, str print '(i0)', kaiseki(s,str,N) end program main