In this

**HackerEarth The Normal Type problem solution**There are a lot of Poke'mons who are jealous of the fact that they do NOT have any specialty, they're the... normal type of Poke'mon. But, what they fail to realize is that their power is their normalcy, the ability to think, rationalize and then act.But, they do have an additional power... Poke'mons like Jigglypuff - which are normal, can figure out if a trainer is real or is a part of Team Rocket. And they need to use their power to a great extent.

In an array, which consists of N elements, A1, A2, ..., AN, if a subarray has the total number of distinct elements as that of the original array, that determines the presence of Team Rocket.

You've to help the normal type Poke'mons in figuring out the total number of subarrays having total number of distinct elements same as that of the original array.

## HackerEarth The Normal Type problem solution.

`#include <iostream>`

#include <sstream>

#include <fstream>

#include <string>

#include <iomanip>

#include <vector>

#include <deque>

#include <queue>

#include <stack>

#include <set>

#include <map>

#include <algorithm>

#include <functional>

#include <utility>

#include <bitset>

#include <cmath>

#include <cstdlib>

#include <ctime>

#include <cstdio>

using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)

#define ll long long int

#define f first

#define s second

#define pi pair<ll, ll>

#define pii pair<pi,int>

#define f first

#define s second

#define pb push_back

#define mp make_pair

#define pb push_back

#define rep(i,n) for(int i=0;i<n;i++)

#define maxn 3000001

int A[200011];

int main(){

freopen("in10.txt","r",stdin);

freopen("out10.txt","w",stdout);

int N;

cin >> N;

set<int>parent;

rep(i,N){

cin >> A[i];

parent.insert(A[i]);

}

ll ans=0;

set<int>s;

int j=0;

map<int,int>M;

rep(i,N){

j=max(j,i);

while(j<N and s.size()<parent.size()){

M[A[j]]++;

if(M[A[j]]==1){

s.insert(A[j]);

}

j++;

}

if(s.size()==parent.size())

ans+=N-j+1;

M[A[i]]--;

if(M[A[i]]==0) s.erase(A[i]);

}

cout<<ans;

}

## 0 Comments