#P11790. Wind Temperature Calculation

    ID: 13887 Type: Default 1000ms 256MiB

Wind Temperature Calculation

Wind Temperature Calculation

You are given an array \(A\) of \(N+1\) altitudes, where the altitudes are denoted as \(A_i\) for \(i=0,1,\dots,N\). It is guaranteed that \(A_0=0\). There is a wind blowing from location 0 to location \(N\). As the wind passes from one location to the next, its temperature changes according to the following rules:

  • If \(A_i=A_{i+1}\), the temperature remains unchanged.
  • If \(A_i>A_{i+1}\), the wind's temperature increases by \((A_i-A_{i+1})\times T\) degrees (due to a decrease in altitude).
  • If \(A_i<A_{i+1}\), the wind's temperature decreases by \((A_{i+1}-A_i)\times S\) degrees (due to an increase in altitude).

Assume that the initial temperature at location 0 is 0. Your task is to determine the final temperature of the wind when it reaches location \(N\).

Note: The formulas involving differences and multipliers \(T\) and \(S\) must be written in LaTeX format as shown above.

inputFormat

The input consists of two lines:

  1. The first line contains three integers \(N\), \(T\), and \(S\), where \(N\) represents the number of transitions (i.e. there are \(N+1\) locations), \(T\) is the increase multiplier for a descent, and \(S\) is the decrease multiplier for an ascent.
  2. The second line contains \(N+1\) integers \(A_0, A_1, \dots, A_N\) representing the altitudes. It is guaranteed that \(A_0=0\).

outputFormat

Output a single integer representing the final temperature of the wind at location \(N\).

sample

3 2 3
0 0 1 1
-3