1999 LSU Computer Science High School Programming Contest
Novice Problem 6
Orange Barrels

When highways are being worked on, the repair crews use Orange Barrels to tell you when you can/should move over (lanes are closed or they re-open). The Larry-Darrel-Darrel Construction Company always puts 13 Orange Barrels before a lane ends (13 per each lane). They always put 9 Orange Barrels when you regain a lane. You are to read in a series of lane widths and determine how many barrels you see while traveling that stretch of road and how many times the number of lanes changes.

Sample Input Data:

3 
2 
4 
3
0
4 
5 
2 
3 
4 
5 
6 
3 
4 
5
0
-1

NOTE: Each highway will end when you encounter a zero (0). You will stop processing when you encounter a negative one (-1).

Sample Output:

This highway changed width 3 times and we saw 44 Orange Barrels.
This highway changed width 9 times and we saw 141 Orange Barrels.

NOTE: Do not worry about the formatting of numeric output (leading/trailing spaces around numbers are acceptable).

Explanation of Calculation:

The highway 3 2 4 3 would be calculated as follows:

    The highway starts at 3 lanes wide and you have seen no barrels
  1. The highway narrows by 1 lane to 2 lanes wide and you see 13 barrels for a total of 13 barrels
  2. The highway widens by 2 lanes to 4 lanes wide and you see 18 barrels for a total of 31 barrels
  3. The highway narrows by 1 lane to 3 lanes wide and you see 13 barrels for a total of 44 barrels



Return to the Top of Page, First Page, Novice Problem Set, or Veteran Problem Set.


Clarifications:







Return to the Top of Page, First Page, or Novice Problem Set.



The statements and opinions included in these pages are those of the LSU High School Programming Contest Staff only. Any statements and opinions included in these pages are not those of Louisiana State University or the LSU Board of Supervisors.
© 1999 LSU High School Programming Contest

Return to the LSU High School Programming Contest Homepage