blob: 107281bf2602e88c2ec4000726477ca47551a2e2 (
plain) (
blame)
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
|
#include <iostream>
unsigned max(unsigned a, unsigned b) {
return a > b ? a : b;
}
unsigned longestIncreasing(int* nums, unsigned size, unsigned current) {
if (size <= 1)
return current + size;
if (nums[0] < nums[1])
return longestIncreasing(nums + 1, size - 1, current + 1);
else
return max(current + 1, longestIncreasing(nums + 1, size - 1, 0));
}
unsigned longestIncreasing(int* nums, unsigned size) {
return longestIncreasing(nums, size, 0);
}
int main() {
unsigned N;
std::cin >> N;
int* nums = new int[N];
for (unsigned i = 0; i < N; ++i)
std::cin >> nums[i];
std::cout << longestIncreasing(nums, N) << std::endl;
delete[] nums;
return 0;
}
|