General
 
 
# Author Problem Lang Verdict Time Memory Sent Judged  
82748202 Practice:
SarthakBansal
255C - 28 GNU C++11 Accepted 156 ms 125276 KB 2020-06-07 07:13:59 2020-06-07 07:13:59
→ Source
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define f(i,a,b) for(ll i=a;i<b;i++)

void solve()
{
    ll n;cin>>n;
    map<ll,ll> m;ll ind=0;
    ll a[n];
   
    f(i,0,n) {cin>>a[i];
    	if(m.count(a[i])==0){
    		m[a[i]]=ind;ind++;}
    }
    f(i,0,n) a[i]=m[a[i]];
    //map m is useless now
    
ll ans=0;
ll dp[n][n];
f(i,0,n)  f(j,0,n) { dp[i][j]=1; } 

f(i,0,n)
{
	f(j,0,i)
	{
		dp[i][a[j]]=max(1+dp[j][a[i]],dp[i][a[j]]);
	}
}

f(i,0,n)
f(j,0,n) {ans=max(ans,dp[i][j]);}


cout<<ans;
}

int main()
{

ios_base::sync_with_stdio(false);
    cin.tie(NULL);

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