#P10174. 「OICon-02」Great Segments
「OICon-02」Great Segments
Background
upd: The time limit has been changed to 400 ms.
Recommended enhanced version of the problem
Problem Description
You are given a sequence of length with no repeated elements.
For an interval , we define it to be good if it satisfies the following conditions:
- Define a sequence $b=\{ a_l,\max(a_l,a_{l+1}),\max(a_l,a_{l+1},a_{l+2}),\ ...\ ,\max(a_l,a_{l+1},\ ... \ ,a_r)\}$. After removing duplicates from this sequence, its length is at most and greater than .
- .
Please solve the following problem: For each , how many good intervals satisfy .
Input Format
The first line contains two integers .
The second line contains integers, where the -th number denotes .
Output Format
Output lines, each containing one integer. The number on the -th line denotes how many good intervals in the sequence satisfy .
4 2
1 3 2 4
1
2
2
2
Hint
Sample Explanation
For sample , the intervals that satisfy the conditions are:
- .
- .
- .
Therefore, when , the following intervals satisfy (by the interval indices above):
- interval.
- intervals .
- intervals .
- intervals .
Constraints
This problem uses bundled testdata.
| Special Property | ||
|---|---|---|
| increasing | ||
| No special restrictions |
For of the testdata: , .
Translated by ChatGPT 5