我无法绑定UVa账号,求帮看
查看原帖
我无法绑定UVa账号,求帮看
1355828
MSJ2013楼主2025/7/27 13:47
#include<bits/stdc++.h>
using namespace std;
int main(){
	int t;
    cin>>t;
    for(int i=1;i<=t;i++){
        int n,a[1000000]={0};
        cin>>n;
        for(int j=1;j<=n;j++){
            cin>>a[j];
        }
        int l=1,r=1,maxx=0;
        map<int ,int>m;
        for(;r<=n;r++){
            m[a[r]]++;
            while(m[a[r]]>1){
                maxx=max(maxx,r-l);
                m[a[l]]--;
                l++;
            }
        }
        cout<<maxx<<" ";
    }
}

谢了

2025/7/27 13:47
加载中...