-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTwistyMovement.cpp
More file actions
55 lines (43 loc) · 1.04 KB
/
TwistyMovement.cpp
File metadata and controls
55 lines (43 loc) · 1.04 KB
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
54
55
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <vector>
using namespace std;
int main() {
int n;
scanf("%d", &n);
int *dragon = new int[n];
for(int i = 0; i < n; i++) {
scanf("%d", &dragon[i]);
}
int cnt = 1;
vector<int> points;
for(int i = 1; i < n; i++) {
if(dragon[i - 1] <= dragon[i]) {
cnt++;
if(i == n - 1) {
points.push_back(cnt);
}
}else if(dragon[i - 1] > dragon[i]) {
points.push_back(cnt);
cnt = 1;
}
}
cout << "=====" << endl;
for(int i = 0; i < points.size(); i++) {
cout << points[i] << endl;
}
cout << "=====" << endl;
int max = 0;
for(int i = 0, len = points.size(); i < len - 1; i++) {
int point1 = points[i];
int point2 = points[i + 1];
if(max < point1 + point2) {
max = point1 + point2;
}
}
printf("%d\n", max);
return 0;
}