NONSTOP - No Red Lights Pl !!

no tags 

A call centre employee X works the late shift and leaves his company's parking lot at precisely 4:00 AM every morning. His route home is by a straight road which has four traffic signals at fixed locations but varying Green, Yellow and Red timings. X has always wondered if, given the locations and cycles of each of the traffic signals, are there velocities he can travel home without ever having to speed up or slow down on account of a red signal light. You are to write a program to satisfy his curiosity. Your program should find the maximum integer speed (in km per hour) which can be used for X's trip home. Each speed is a rate (in km per hour) he can maintain the moment he leaves the parking lot at 4:00 AM until he arrives at a traffic signal. He can change the speed at every traffic signal and maintain it till the next signal such that he never passes through a red signal. Since X is a relatively law-abiding citizen, you need only consider speeds in the range 55-60. Also when light changes from yellow to red he must not cross it. If no such speeds are possible then print "not possible".

The optimum speed for a section is the maximum allowable speed so that he can reach home soon to have a good nap.

All traffic signal turns green at exactly 4 a.m. everyday. The distance is as follows:

Office - Signal 1 50 KM
Signal 1 - Signal 2 20KM
Signal 2 - Signal 3 40KM
Signal 3 - Signal 4 12KM
Signal 4 - House 10KM

Input

The input consists of 4 lines and 3 integers in each line for 'G' 'Y' 'R' values indicating the time in seconds the traffic light remains in green, yellow or red respectively.

Output

It must contain five lines and each line indicating the maximum speed he can travel in that interval.

Sample

Input:
30 15 45 
18 8 25
20 30 40
10 10 30

Output:
60
60
60
57
60

hide comments
যোবায়ের: 2010-08-24 15:30:27

seems confusing, what I understand is:
"output maximum possible speed in each interval" so that, "he can reach home soon", i.e. in minimum total time.

Am I correct?


Added by:paradigm2k10
Date:2010-08-22
Time limit:10s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ADA95 ASM32 ASM64 BASH BF CSHARP CPP14 C99 CLPS LISP sbcl LISP clisp D ERL FORTRAN HASK ICON ICK JS-RHINO LUA NEM NICE OBJC OCAML PAS-GPC PAS-FPC PERL PHP PIKE PRLG-swi PYTHON RUBY SCALA SCM guile SCM qobi ST SQLITE TCL WHITESPACE
Resource:FICTIOUS