cf/mirror

Good Subarrays (Hard Version)

CF
1736C22400· grandmaster3s256 MB⌨ stdin/stdout

Examples

Sample 1of 2
Input
4
2 4 1 4
3
2 4
3 3
2 1
Output
6
10
5
Sample 2of 2
Input
5
1 1 3 2 1
3
1 3
2 5
4 5
Output
7
9
8
1736C2.cpp
loading editor…
Ln 11·137 BGNU C++20 (64)