Skip to content

Commit 80c5049

Browse files
committed
Create 66B - Petya and Countryside.cpp
1 parent 637ff8e commit 80c5049

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

66B - Petya and Countryside.cpp

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
//4306556 Aug 18, 2013 7:48:28 AM fuwutu 66B - Petya and Countryside GNU C++0x Accepted 30 ms 0 KB
2+
#include <cstdio>
3+
4+
int main()
5+
{
6+
int n, height[1000], left[1000] = {0}, right[1000] = {0};
7+
scanf("%d", &n);
8+
for (int i = 0; i < n; ++i)
9+
{
10+
scanf("%d", &height[i]);
11+
}
12+
13+
for (int i = 1; i < n; ++i)
14+
{
15+
left[i] = (height[i] >= height[i-1] ? left[i-1] + 1 : 0);
16+
}
17+
for (int i = n - 2; i >= 0; --i)
18+
{
19+
right[i] = (height[i] >= height[i+1] ? right[i+1] + 1 : 0);
20+
}
21+
22+
int maximal(0);
23+
for (int i = 0; i < n; ++i)
24+
{
25+
if (left[i] + right[i] + 1 > maximal)
26+
{
27+
maximal = left[i] + right[i] + 1;
28+
}
29+
}
30+
printf("%d\n", maximal);
31+
return 0;
32+
}

0 commit comments

Comments
 (0)