Source Code
#include <bits/stdc++.h>
using namespace std;
int N = 3000001; 
int M = 1000001;
int main() {
	vector<vector<int>>v ; 
	v.resize(N) ; 
	int n; 
	scanf("%d" , &n) ; 
	
	for (int i =0 ; i<n ; ++i) {
		int x ; 
		scanf("%d" , &x) ; 
		x+=M ; 
		v[x].push_back(i) ; 
	}
	int mx = 1;
	for(int i =0 ; i<N ; ++i) {
		if (v[i].size() >= 2) {
			for (int j =1 ; j<v[i].size() ; ++j) {
				mx = max(mx , v[i][j]-v[i][j-1]+1) ; 
			}
		}
		
	}
	printf("%d\n" , mx) ; 
	return 0;
	
}
Copy
Good Segment Chicou
GNU G++17
81 ms
70.9 MB
Wrong Answer