Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- int n;
- cin >> n;
- int a[1000005] = {0};
- int ans = 0;
- for(int i = 0; i < n; ++i)
- {
- int tmp;
- cin >> tmp;
- a[tmp + 1]++;
- a[tmp]++;
- a[tmp + 2] = a[tmp - 1] = 0;
- ans = max(ans, max(a[tmp], a[tmp + 1]));
- }
- cout << ans << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement