makrusak

Progression

Sep 30th, 2012
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.09 KB | None | 0 0
  1. #include <cstdio>
  2. #include <iostream>
  3. #include <algorithm>
  4. #include <vector>
  5. #include <string>
  6. #include <queue>
  7. #include <map>
  8. #include <set>
  9. #include <cmath>
  10. #include <sstream>
  11. #include <stack>
  12. #include <cassert>
  13.  
  14. #define pb push_back
  15. #define mp make_pair
  16. #define PI 3.1415926535897932384626433832795
  17. #define sqr(x) (x)*(x)
  18. #define forn(i, n) for(int i = 0; i < n; ++i)
  19. #define ALL(x) x.begin(), x.end()
  20. #define F first
  21. #define S second
  22. #define m0(x) memset(x,0,sizeof(x))
  23. #define CC(x) cout << (x) << "\n"
  24. #define pw(x) (1ull<<(x)).
  25.  
  26. using namespace std;
  27. typedef long long ll;
  28. typedef unsigned long long ull;
  29. typedef long double ld;
  30. typedef pair<int,int> pii;
  31. const int INF = 2147483647;
  32. const ll LLINF = 9223372036854775807LL;
  33.  
  34. int a[100500];
  35.  
  36. int main() {
  37.   freopen("progression.in", "r", stdin);
  38.   freopen("progression.out", "w", stdout);
  39.   int n;
  40.   cin >> n;
  41.   forn(i,n) cin >> a[i];
  42.   int l=0;
  43.   int r=1;
  44.   int max=-1;
  45.   while (l<n-1) {
  46.     while (r+1<n && a[r+1]-a[r]==a[l+1]-a[l]) r++;
  47.     if (r-l+1>max) max=r-l+1;
  48.     l=r;
  49.   }
  50.   CC(max);
  51.   return 0;
  52. }
Advertisement
Add Comment
Please, Sign In to add comment