blob: 4c9c0ba58c4f21191c2b6ac7732c8b87a0078d41 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
#include <iostream>
int N;
int seq[10000];
int main() {
std::cin >> N;
for (int i = 0; i < N; i++) {
std::cin >> seq[i];
}
int count = N;
for (int start = 0; start < N; start++) {
int min = seq[start], max = seq[start];
for (int end = start + 1; end < N; end++) {
int current = seq[end];
if (current > max) {
max = current;
}
if (current < min) {
min = current;
}
if (max - min == end - start) {
count++;
}
}
}
std::cout << count;
return 0;
}
|