Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- #define int long long
- const int N = 1e5 + 5;
- const int mod = 1e18 + 7;
- const int INF = 1e18;
- int dp[N];
- int from[N];
- int a[N];
- signed main()
- {
- int n;
- cin >> n;
- map<int , int> cnt;
- for(int i = 0; i < n; i++){
- cin >> a[i];
- cnt[a[i]]++;
- }
- int ans = 1;
- for(int i = 0; i < n; i++){
- ans = max(ans , cnt[a[i]] + cnt[a[i] + 1]);
- }
- cout << ans << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement