

Time Limit: 3 sec / Memory Limit: 976 MB
配点: 点
問題文
高橋王国には, 東西にのびる 本の線路がある. これに沿って 個の都市があり, 西から順に都市 と番号づけられている.
AtCoder Express という会社は 本の列車を保有しており, 列車 は都市 から都市 の区間 ( の場合もある) を走っている.
この王国の国王である高橋君は, 個のことに興味を持った. 具体的には, のときの以下の質問の答えを求めたくなった.
- 都市 から都市 までの区間に, 走る区間が 完全に含まれる 列車の本数. 言い換えれば, と が両方成り立つような列車 の本数.
高橋君は天才である. しかし流石の彼でも, 膨大なデータを処理することはできない. 高橋君のために, 個の質問それぞれに対して答えを求めよ.
制約
- は 以上 以下の整数
- は 以上 以下の整数
- は 以上 以下の整数
入力
入力は以下の形式で標準入力から与えられる.
出力
行出力せよ. 行目には, 都市 から都市 までの区間に, それぞれの走る区間が完全に含まれる列車の本数を出力せよ.
入力例 1Copy
2 3 1 1 1 1 2 2 2 1 2
出力例 1Copy
3
全ての列車の走る区間が, 都市 から都市 までの区間に含まれているので, この質問の答えは となる.
入力例 2Copy
10 3 2 1 5 2 8 7 10 1 7 3 10
出力例 2Copy
1 1
個目の質問は, 都市 から までの区間についてである. その区間に走る区間が完全に含まれている列車は, 列車 のみである. 個目の質問は, 都市 から までの区間についてである. その区間に走る区間が完全に含まれている列車は, 列車 のみである.
入力例 3Copy
10 10 10 1 6 2 9 4 5 4 7 4 7 5 8 6 6 6 7 7 9 10 10 1 8 1 9 1 10 2 8 2 9 2 10 3 8 3 9 3 10 1 10
出力例 3Copy
7 9 10 6 8 9 6 7 8 10
Score: points
Problem Statement
In Takahashi Kingdom, there is a east-west railroad and cities along it, numbered , , , ..., from west to east. A company called AtCoder Express possesses trains, and the train runs from City to City (it is possible that ). Takahashi the king is interested in the following matters:
- The number of the trains that runs strictly within the section from City to City , that is, the number of trains such that and .
Although he is genius, this is too much data to process by himself. Find the answer for each of these queries to help him.
Constraints
- is an integer between and (inclusive).
- is an integer between and (inclusive).
- is an integer between and (inclusive).
Input
Input is given from Standard Input in the following format:
Output
Print lines. The -th line should contain the number of the trains that runs strictly within the section from City to City .
Sample Input 1Copy
2 3 1 1 1 1 2 2 2 1 2
Sample Output 1Copy
3
As all the trains runs within the section from City to City , the answer to the only query is .
Sample Input 2Copy
10 3 2 1 5 2 8 7 10 1 7 3 10
Sample Output 2Copy
1 1
The first query is on the section from City to . There is only one train that runs strictly within that section: Train . The second query is on the section from City to . There is only one train that runs strictly within that section: Train .
Sample Input 3Copy
10 10 10 1 6 2 9 4 5 4 7 4 7 5 8 6 6 6 7 7 9 10 10 1 8 1 9 1 10 2 8 2 9 2 10 3 8 3 9 3 10 1 10
Sample Output 3Copy
7 9 10 6 8 9 6 7 8 10