forked from kothariji/competitive-programming
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPlaylist.cpp
54 lines (45 loc) · 878 Bytes
/
Playlist.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include<bits/stdc++.h>
#include<iostream>
using namespace std;
#define mod 1000000007
#define all(x) (x).begin(), (x).end()
typedef long long ll;
void subMain(){
int n;
cin >> n;
vector<int > v;
map<int ,bool > mymap;
int maxx=0;
int currans=0;
int j=0;
for(int i=0;i<n;i++){
int k;
cin>>k;
v.push_back(k);
if(mymap.find(k)==mymap.end()||mymap[k]==false){
mymap[k]=true;
currans++;
maxx=max(currans,maxx);
}
else{
while(v[j]!=k){
mymap[v[j]]=false;
j++;
}
currans=(i-j);
j++;
}
}
cout<<maxx<<endl;
}
int32_t main(){
ios_base::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
/*ll t=1;
cin >> t;
while(t--){
subMain();
}*/
subMain();
return 0;
}