program main implicit none integer*8::r,g,b,tmp,diff integer*8::i,j data j/0/ read *,r,g,b j=MIN(MIN(r,g),b) r = r - j g = g - j b = b - j call sort(r,g,b) if(r.eq.0) then print '(i0)',j return else if(g.eq.0) then print '(i0)',j+r/4 return end if if(r.ge.3*g) then print '(i0)',j+g+(r-3*g)/5 return end if diff = (r - g)/2 j = j + diff r = r - 3*diff g = g - diff diff = MIN(r,g)/4 j = j + diff*2 r = r - diff*4 g = g - diff*4 call sort(r,g,b) if(r.gt.3.and.g.gt.1) then j = j + 1 end if print '(i0)',j contains subroutine sort(r,g,b) integer*8::r,g,b,tmp if(r.lt.g) then tmp = g g = r r = tmp end if if(g.lt.b) then tmp = g g = b b = tmp end if if(r.lt.g) then tmp = g g = r r = tmp end if end subroutine sort end program main