-
Notifications
You must be signed in to change notification settings - Fork 93
/
LongArithSubarray.cpp
63 lines (55 loc) · 1.44 KB
/
LongArithSubarray.cpp
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
56
57
58
59
60
61
62
63
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <climits>
#include <vector>
#include <set>
#include <algorithm>
using namespace std;
#define ll long long int
#define ld long double
#define mod 1000000007
#define endl "\n"
#define vi vector<ll>
#define vs vector<string>
#define pii pair<ll, ll>
#define ump unordered_map
#define mp map
#define pq_max priority_queue<ll>
#define pq_min priority_queue<ll,vi,greater<ll>
#define ff first
#define ss second
#define mid(l,r) (l+(r-l)/2)
#define loop(i,a,b) for(int i=(a); i <=(b);i++)
#define looprev(i,a,b) for(int i=(a); i >=(b);i--)
#define clr(val) memset(val,0,sizeof(val))
#define what_is(x) cerr << #x << " is " << x << endl;
#define OJ \
freopen("input.txt", "r", stdin); \
freopen("output.txt", "w", stdout);
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
int main()
{
ll n;
cin>>n;
vector <ll> dp(n);
loop(i,0,n-1) cin>>dp[i];
ll pd = dp[1] - dp[0];
ll ans = 2;
ll j = 2;
ll curr = 2;
while(j < n){
if (pd == dp[j] - dp[j-1]){
curr++;
}
else{
pd = dp[j] - dp[j-1];
curr = 2;
}
ans = max(ans,curr);
j++;
}
cout<<ans;
return 0;
}