'commit'
This commit is contained in:
33
TangDou/LuoGuBook/P1420_2.cpp
Normal file
33
TangDou/LuoGuBook/P1420_2.cpp
Normal file
@@ -0,0 +1,33 @@
|
||||
#include <bits/stdc++.h>
|
||||
using namespace std;
|
||||
const int N = 1e4 + 10;
|
||||
|
||||
//常数,正无穷大
|
||||
const int INF = 0x3f3f3f3f;
|
||||
|
||||
int a[N];
|
||||
int Max = -INF, len = 1;
|
||||
/*
|
||||
1 1
|
||||
|
||||
一个数字,这个数字是1
|
||||
最长的连续长度是几?
|
||||
1
|
||||
|
||||
*/
|
||||
int main() {
|
||||
int n;
|
||||
cin >> n;
|
||||
for (int i = 1; i <= n; i++) {
|
||||
cin >> a[i];
|
||||
if (i > 1) {
|
||||
if (a[i] - a[i - 1] == 1)
|
||||
len++;
|
||||
else
|
||||
len = 1;
|
||||
}
|
||||
Max = max(Max, len);
|
||||
}
|
||||
cout << Max << endl;
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user