-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathday_tam_giac_dai_nhat.cpp
More file actions
53 lines (49 loc) · 898 Bytes
/
Copy pathday_tam_giac_dai_nhat.cpp
File metadata and controls
53 lines (49 loc) · 898 Bytes
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include <bits/stdc++.h>
using namespace std;
void testCase()
{
int n;
cin >> n;
int a[100005], l[100005] = {}, r[100005] = {};
for (int i = 1; i <= n; i++)
{
cin >> a[i];
}
for (int i = 1; i <= n; i++)
{
if (a[i] > a[i - 1])
{
l[i] = l[i - 1] + 1;
}
else
l[i] = 1;
}
for (int i = n; i >= 1; i--)
{
if (a[i] > a[i + 1])
{
r[i] = r[i + 1] + 1;
}
else
r[i] = 1;
}
int maxX = 0;
for (int i = 1; i <= n; i++)
{
maxX = max(maxX, l[i] + r[i] - 1);
}
cout << maxX;
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int t;
cin >> t;
while (t--)
{
testCase();
cout << endl;
}
}