Statistics

Problem Statement for "PowerPlant"

Problem Statement

PROBLEM STATEMENT

A nuclear power plant owner has recently fired an incompetent technician.  You
are his replacement.  
Your job is to regulate the power output of a very shady nuclear core.  It has
the following traits:
(1) the core has "critical" days when its power output has to be some
specific value.  
(2) on non-critical days, the core runs fine at any power output between 0MW
and 2000MW, inclusive.
  (3) the power output can only be changed once a day.
(4) the power output can either be increased by 100MW, be decreased by 100MW,
or be held constant.
The plant is therefore forced to run in irregular periods marked off by
critical days.  At the start of each period the nuclear engineers tell you
about the power output on critical days (the first and last days of the
period), while the statisticians give you a forecast of the expected power
demand for the days between the critical days.  You have to regulate the power
output with the following in mind:
(1) on the first day the core is at the level of the first critical day level
and cannot be changed.
(2) when possible, the power demand on non critical days will have to be
exactly met.
  (3) the power output should be lowered whenever possible to save money.
(4) on the last day of the period, the core has to end up at the second
critical day level.
Sometimes it will be impossible to meet the demand, and the customers will have
to be alerted so that 
they can purchase the additional power from elsewhere.  Write a method which
will determine if it is possible to meet the demand every day.  If it is
impossible return -1, if it is possible, return the lowest power output of the
core during the entire period.

Class: PowerPlant
Method: output
Parameters: int[]
Returns: int
Method signature: (be sure your method is public) int output(int[] schedule);

TopCoder will ensure the validity of the inputs. Inputs are valid if all of the
following criteria are met:
-schedule contains between 2 and 50 elements, inclusive.
-Each element of schedule is between 0 and 2000, inclusive, and is a multiple
of 100.      

EXAMPLES
The bar graphs on the left of each example show the power demand for each day,
they do not show
what the output should be.

Example 1:   schedule = {100,500,200}
         
 X  500  Days 0 and 2 are critical days.
 X  400	 In this case the demand on day 1 could not be met because it would mean
 X  300  that the output of the core would have to increase by 400MW in one day.
 XX 200  The core output can only change by 100MW in one day. 
XXX 100  The method returns -1.
012

Example 2:    schedule = {300,100}
X  300   Days 0 and 1 are critical days.
X  200   In this case the reactor cannot meet the critical output on day 1
because
XX 100   its power output would have to be reduced by more than 100MW in one day.
01       The method returns -1.

Example 3:  schedule = {400,100,100,100,400}

X   X 400  Days 0 and 4 are critical days.
X   X 300  Start at 400 on day 0.  Decrease to 300 on day 1, decrease to 200 on
day 2,
X   X 200  increase to 300 on day 3 so that you will be able to increase to 400
on day 4
XXXXX 100  to meet the critical level.  The power demand was met on each non
critical day.
01234      The method returns 200.

Example 4:  schedule = {300,400,100,200,100}

 X    400  Days 0 and 4 are critical days.
XX    300  Start at 300 on day 0.  Increase to 400 on day 1, decrease to 300 on
day 2,
XX X  200  decrease to 200 on day 3, and decrease to 100 on 4 to meet the
critical level.
XXXXX 100  The power demand was met on each non critical day.
01234      The method returns 100.

Definition

Class:
PowerPlant
Method:
output
Parameters:
int[]
Returns:
int
Method signature:
int output(int[] param0)
(be sure your method is public)

Constraints

    Examples


      This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2024, TopCoder, Inc. All rights reserved.
      This problem was used for: