General
 
 
# Author Problem Lang Verdict Time Memory Sent Judged  
90312551 Practice:
PremKapshi1234
1208B - 39 GNU C++17 Time limit exceeded on test 27 2000 ms 808 KB 2020-08-18 16:39:38 2020-08-18 16:39:38
 
 
→ Source
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
using namespace std;
#define Fio                           \
    ios_base::sync_with_stdio(false); \
    cin.tie(nullptr);                 \
    cout.tie(nullptr)
#define f(i, n) for (long long int i = 0; i < n; i++)
#define ll long long int
#define fo(i, a, b) for (long long int i = a; i <= b; i++)
#define w(t)  \
    int t;    \
    cin >> t; \
    while (t--)
#define vi vector<int>
#define vl vector<long long int>
#define vvi vector<vector<int>>
#define vvl vector<vector<long long int>>
#define mii map<int, int>
#define mll map<ll,ll>
#define umii unordered_map<int, int>
#define newl cout<<"\n"
#define pb push_back
#define mp make_pair
#define fi first
#define se second
const ll inf = 1e9 + 7;
const ll modc = 998244353;
#define MAX 200006

ll mini(ll a,ll b){
    if(a>=b)return b;
    return a;
}

ll maxi(ll a,ll b){
    if(a>=b)return a;
    return b;
}

int check(ll x,vl &A){
    ll n = A.size();
    for(ll i = 0;i<=n-x;i++){
        int f=0;
        unordered_map<ll,ll> cnt;
        for(ll j = 0;j<i;j++){
            cnt[A[j]]++;
            if(cnt[A[j]]>=2){
                f=1;
                break;
            }
        }   
        for(ll j = i+x;j<n;j++){
            cnt[A[j]]++;
            if(cnt[A[j]]>=2){
                f=1;
                break;
            }
        }
        if(f==0)return 1;
    }
    return 0;
}

int main(){
    Fio;
    ll n;
    cin>>n;
    vl A(n);
    f(i,n)cin>>A[i];
    ll l = 0,r = 2*n;
    int ans = 0;
    while(l<=r){
        ll mid = (l+r)/2;
        // cout<<mid<<" "<<check(mid,A);
        // newl;
        if(check(mid,A))r = mid-1,ans = mid;
        else l = mid+1;
    }
    cout<<ans;

    return 0;
}
 
 
?
Time: ? ms, memory: ? KB
Verdict: ?
Input
?
Participant's output
?
Jury's answer
?
Checker comment
?
Diagnostics
?
Click to see test details