PROBLEM STATEMENT
On the seventh of each month I sit down and write two checks: my rent payment
and my payment for saxophone lessons. I always do it in the same order, which
means that my check number for the saxophone payment is always the next number
compared to my rent payment. My rent payment is my biggest payment of the month.
Your task is, given the check numbers for the current month and the payment
amounts on the corresponding checks, return the amount I pay for saxophone
lessons.
DEFINITION
Class: Saxophone
Method: payment
Parameters: int[], int[]
Returns: int
Method signature (be sure your method is public): int payment(int[] checkNums,
int[] checkValues);
TopCoder will ensure the validity of the inputs. Inputs are valid if all of the
following criteria are met:
- checkNums contains between 2 and 15 elements inclusive
- checkValues contains the same number of elements as checkNums
- each element of checkNums is between 101 and 2000 inclusive
- when put in ascending order the elements of checkNums form a consecutive
sequence (e.g. 3, 4, 5, 6, 7) (note that this implies that they are all
different)
- each element of checkValues is between 1 and 2000 inclusive
- checkValues has exactly one element corresponding to the maximum value
- the maximum element of checkValues doesn't correspond to the maximum element
of checkNums
EXAMPLES
1. checkNums = {101,102}, checkValues = {2000,200}, return 200
2. checkNums = {101,102,103,104,105,106,107}, checkValues = {2,3,4,5,6,7,1},
return 1
3. checkNums = {210,209,208,207,206,205,204,203,202,201}, checkValues =
{100,100,100,1500,100,100,100,100,100,100}, return 100
4. checkNums = {305,304,303,302,301,300,299,298,297,296}, checkValues =
{185,200,20,112,1450,720,30,97,81,15}, return 112