No.2065 Sum of Min
問題文最終更新日: 2024-02-04 15:41:07
English (AI translation)
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence.
Back to the original
yukicoder contest 359
(順位表)
の他の問題:
Problem Statement
For each $i=1,2,\ldots,Q$, find $\displaystyle\sum_{k=L_i}^{R_i}\min(X_i,A_k)$.
Input
$N\ Q$ $A_1\ A_2 \ldots A_N$ $L_1\ R_1\ X_1$ $L_2\ R_2\ X_2$ $\vdots$ $L_Q\ R_Q\ X_Q$
Output
Print $Q$ lines.
On line $i$ $(1\le i\le Q)$, print the value of $\displaystyle\sum_{k=L_i}^{R_i}\min(X_i,A_k)$.
Sample
Sample 1
Input
3 3 1 2 4 1 3 5 2 3 3 1 3 1
Output
7 5 3
$\displaystyle\sum_{k=1}^3\min(5,A_k)=1+2+4=7$. Therefore, print $7$ on line $1$.
$\displaystyle\sum_{k=2}^3\min(3,A_k)=2+3=5$. Therefore, print $5$ on line $2$.
$\displaystyle\sum_{k=1}^3\min(1,A_k)=1+1+1=3$. Therefore, print $3$ on line $3$.
Sample 2
Input
5 1 1000000000 1000000000 1000000000 1000000000 1000000000 1 5 1000000000
Output
5000000000
Note that the output may not fit in a 32-bit integer type.
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。
とりゐ