MathWorksOA #6
Investable Periods
估计困难可在线判题
考点(AI 标注)双指针滑窗
Given daily prices, a target minimum price, and a target maximum price, count the contiguous subarrays whose minimum is exactly the target minimum price and whose maximum is exactly the target maximum price.
See below for this site's input/output protocol.
输入格式
The first line contains n min_price max_price, and the next line contains n prices. 1≤n≤100000, 1≤price[i]≤10^9, 1≤min_price≤max_price≤10^9.
输出格式
Output the number of qualifying contiguous ranges. The answer may exceed the range of a 32-bit signed integer, so use a 64-bit integer.
样例 1
输入:
5 3 5
4 5 3 3 1
输出:
4
样例 2
输入:
5 1 2
2 2 1 5 1
输出:
2
样例 3
输入:
4 2 3
1 2 3 2
输出:
3