# 題目
AP325 Q-3-11. 最長的相異色彩帶
# 解題思路
目前沒東西...
# 程式碼
#include<bits/stdc++.h> | |
using namespace std; | |
#define N 200005 | |
int a[N],b[N]={0}; | |
int main(){ | |
int n,max1=0; | |
cin>>n; | |
for(int i=0;i<n;i++) | |
cin>>a[i]; | |
for(int right=0,left=0,max2=0;right<n;right++){ | |
b[a[right]]++; | |
max2++; | |
while(b[a[right]]==2){ | |
b[a[left]]--; | |
left++; | |
max2--; | |
} | |
max1=max(max1,max2); | |
} | |
cout<<max1; | |
return 0; | |
} |