General
 
 
# Author Problem Lang Verdict Time Memory Sent Judged  
95397240 Practice:
tmaddy
1208B - 39 GNU C++17 Time limit exceeded on test 5 2000 ms 248 KB 2020-10-13 09:35:25 2020-10-13 09:35:25
 
 
→ Source
#include <bits/stdc++.h>
 
using namespace std;
 
int n;
vector<int> a;
 
// 7 5 4 9
 
bool check(int len) {
 
	for(int i=0; i<=n-len; ++i) {
		// to exclude [i, i + len - 1]
		set<int> s;
		for(int j=0; j<n; ++j) {
			if(j < i || j > i + len - 1) {
				s.insert(a[j]);
			}
		}
		if(s.size() == n - len) {
			return true;
		}
	}
 
	return false;
 
}
 
void solve() {
 
	cin >> n;
	a.resize(n);
 
	for(int i=0; i<n; ++i)
		cin >> a[i];
 
 
	set<int> s;
 
	for(int x: a) s.insert(x);
 
	if(s.size() == n) {
		cout << 0;
		return;
	}
 
	int b = 0;
	int g = n;
 
 
	while(g > b + 1) {
		int mid = (g + b) / 2;
		if(check(mid))
			g = mid;
		else 
			b = mid;
	}
 
	cout << g;
 
 
}
 
int main() {
 
	solve();
 
	return 0;
}
 
 
?
Time: ? ms, memory: ? KB
Verdict: ?
Input
?
Participant's output
?
Jury's answer
?
Checker comment
?
Diagnostics
?
Click to see test details