Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2013
27
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.89 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstdio>
  3. #include <cstring>
  4. #include <string>
  5. #include <sstream>
  6. #include <map>
  7. #include <list>
  8. #include <queue>
  9. #include <set>
  10. #include <algorithm>
  11. #include <climits>
  12. #include <cmath>
  13. #include <cassert>
  14. #include <stack>
  15. #include <bitset>
  16. #include <tr1/unordered_map>
  17. #include <tr1/unordered_set>
  18.  
  19. #define mp make_pair
  20. #define ll long long
  21. #define ull unsigned long long
  22.  
  23. const int INF=(INT_MAX>>2);
  24.  
  25. using namespace std;
  26. int a[100000];
  27. int f[100000+1];
  28. int main() {
  29. //  freopen("me.txt","r",stdin);
  30.     //freopen("out.txt","w",stdout);
  31.     int n,k;
  32.     cin>>n>>k;
  33.     for(int i=0;i<n;cin>>a[i++]) ;
  34.     int nusf=0;
  35.     int r1=0,r2=-1;
  36.     for(int i=0;i<n && r2==-1;++i) {
  37.         ++f[a[i]];
  38.         nusf+=(f[a[i]]==1);
  39.         if(nusf==k) r2=i;
  40.     }
  41.     if(r1!=-1) for(;f[a[r1]]>1;++r1) --f[a[r1]];
  42.     if(r2!=-1) cout<<(r1+1)<<" "<<(r2+1);
  43.     if(r2==-1) puts("-1 -1");
  44.     return 0;
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement