[SOLVED] ADA - mini1

30.00 $

Programming resource
Digital learning resource
Category:
Practical programming resource
Suitable for guided study and reference
Tutor guidance available when needed

Description

5/5 - (1 vote)

Input

The first line of the input contains 4 integers N, x, y, z, denoting the number of bars in the original song and the coefficients used in rating evaluation.

The second line of the input contains N space-separated integers a1,a2,…,aN, where the i-th integer denotes that greatness of the i-th bar.

  • 2 ≤ N ≤ 2 × 105
  • 1 ≤ x,y,z ≤ 104
  • −109 ai ≤ 109,i = 1,2,…,N
Test Group 0 (0 %)

•    Sample Input

Test Group 2 (40 %)

•    x = y = z

Test Group 1 (10 %)

•    N ≤ 2000

Test Group 3 (50 %)

•    No Additional Constraint

Output

Please output an integer S indicating the maximal achievable rating.

Sample Input 1                            Sample Input 2                           Sample Input 3

6 1 1 1                                                              8 59 4 87                                                       3 5358 5926 3141

-12 7 -127 -1 -2 -7                                            0 8 -7 0 5 0 -2 9                                      1 10000 100000000

Sample Output 1                          Sample Output 2                        Sample Output 3

-3                                                                     1239                                                                314159265358

Explanation

  • In the first testcase, S achieves its maximum by taking (`,r) = (4,5), S = 1 · (−1) + 1 · (−2) = −3.
  • In the second testcase, S achieves its maximum by taking (`,r) = (2,8), S = 59 · 8 + 4 · ((−7) + 0 + 5 + (−2)) + 87 · 9 = 1239.
  • In the third testcase, S achieves its maximum by taking (`,r) = (1,3), S = 5358 · 1 + 5926 · 104 + 3141 · 108 = 314159265358.

Hint

Roses are red,

Violets are blue,

See the Test Group 2?

It’s a d´ej`a vu.

Resource details

Understand the Task Before You Use the Resource

Review the requirements, identify the programming concepts involved, study the implementation and test your understanding with your own examples and modifications.