Maximum range sum? 1

Maintain an array under point updates. For each range query, find the maximum of U times a subarray sum plus V times its length over all subarrays inside the range.

Medium5ArrayBrute forcePrefix sumImplementationInterviewNo attempts yetTime limit1sMemory limit128 MB

Problem

You are given a sequence K1,K2,,KNK_1, K_2, \dots, K_N of length NN and two constants UU and VV.

There are QQ queries of two kinds.

  1. Given AA and BB, find the maximum value of U×(Ki+Ki+1++Kj)+V×(ji)U \times (K_i + K_{i+1} + \dots + K_j) + V \times (j - i) over all ii, jj with AijBA \le i \le j \le B.
  2. Given AA and BB, set the value of KAK_A to BB.

Input

The first line contains the integers NN, QQ, UU, and VV. (1N,Q1031 \le N, Q \le 10^3, 5U,V5-5 \le U, V \le 5)

The second line contains the integers K1,K2,,KNK_1, K_2, \dots, K_N. (102Ki102-10^2 \le K_i \le 10^2)

Each of the next QQ lines contains one query as three integers CC, AA, and BB. (0C10 \le C \le 1)

If CC is 0, the query is of the first kind and 1ABN1 \le A \le B \le N. If CC is 1, the query is of the second kind and 1AN1 \le A \le N, 102B102-10^2 \le B \le 10^2.

Output

For each query of the first kind, print its result on its own line.