実行時間制限: 2 sec / メモリ制限: 1024 MiB
配点 : 点
問題文
長さ の整数列 が与えられます。
個のクエリが与えられるので、それぞれについて答えを求めてください。
番目のクエリでは、整数 が与えられるので、 の値を答えとして求めてください。
制約
- 入力される値はすべて整数
入力
入力は以下の形式で標準入力から与えられる。
出力
行出力せよ。 行目には、 番目のクエリに対する答えを出力せよ。
入力例 1Copy
5 4 2 1 3 3 1 2 4 1 4 1 5 3 3
出力例 1Copy
24 44 74 3
番目のクエリについて説明します。
求めるべき値は です。
-
のとき です。
-
のとき です。
-
のとき です。
-
のとき です。
-
のとき です。
-
のとき です。
以上より、求めるべき値は です。
Score : points
Problem Statement
You are given an integer sequence of length .
queries are given, so find the answer for each.
In the -th query, integers and are given, so find as the answer.
Constraints
- All input values are integers.
Input
The input is given from Standard Input in the following format:
Output
Output lines. The -th line should contain the answer to the -th query.
Sample Input 1Copy
5 4 2 1 3 3 1 2 4 1 4 1 5 3 3
Sample Output 1Copy
24 44 74 3
We explain the first query.
The value to be calculated is .
-
When , .
-
When , .
-
When , .
-
When , .
-
When , .
-
When , .
From the above, the value to be calculated is .