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
| #include<iostream> using namespace std;
int main() {
int n; cin >> n; int* p1 = new int[n];
for (int i = 0; i < n; i++) { cin >> *(p1 + i); }
for (int j = 0; j < n; j++) { int count = 0; for (int k = 0; k < n; k++) { if (*(p1 + j + k + 1) == *(p1 + j + k) + 1) { count++; } else { break; } } *(p1 + j) = count + 1; }
int temp = *p1; for (int i = 0; i < n; i++) { if (*(p1 + i) > temp) { temp = *(p1 + i); } }
delete[]p1;
cout << temp;
return 0; }
|