Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstdio>
- #include <cstring>
- #include <string>
- #include <sstream>
- #include <map>
- #include <list>
- #include <queue>
- #include <set>
- #include <algorithm>
- #include <climits>
- #include <cmath>
- #include <cassert>
- #include <stack>
- #include <bitset>
- #include <tr1/unordered_map>
- #include <tr1/unordered_set>
- #define mp make_pair
- #define ll long long
- #define ull unsigned long long
- const int INF=(INT_MAX>>2);
- using namespace std;
- int a[100000];
- int f[100000+1];
- int main() {
- // freopen("me.txt","r",stdin);
- //freopen("out.txt","w",stdout);
- int n,k;
- cin>>n>>k;
- for(int i=0;i<n;cin>>a[i++]) ;
- int nusf=0;
- int r1=0,r2=-1;
- for(int i=0;i<n && r2==-1;++i) {
- ++f[a[i]];
- nusf+=(f[a[i]]==1);
- if(nusf==k) r2=i;
- }
- if(r1!=-1) for(;f[a[r1]]>1;++r1) --f[a[r1]];
- if(r2!=-1) cout<<(r1+1)<<" "<<(r2+1);
- if(r2==-1) puts("-1 -1");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement