为什么全是WA?
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
const int N = 1000100;
long long int n, m, a[N];
long long cnt[N];
int main()
{
cin >> n >> m;
for ( int i = 1; i <= n; i ++ )
{
cin >> a[i];
}
long long l = 1, r = 0;
long long tmp = 0, x, y;
while(1)
{
while ( tmp < m && r < n )
{
if ( cnt[a[r++]]++ == 0 )
{
tmp ++;
}
}
if ( tmp < m )
{
break;
}
if ( r - l + 1 < y - x + 1 )
{
y = r, x = l;
}
if ( -- cnt[a[l++]] == 0 )
{
tmp --;
}
}
cout << x << " " << y;
return 0;
}