Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- #include <ext/pb_ds/tree_policy.hpp>
- #include <ext/pb_ds/assoc_container.hpp>
- using namespace std;
- using namespace __gnu_pbds;
- typedef long long ll;
- typedef unsigned long long ull;
- typedef pair<ll,ll>pll;
- typedef pair<int,int>pii;
- //typedef pair<int,pair<int,int>>piii;
- typedef pair<ll,pair<ll,ll>>plll;
- typedef tree<ll, null_type, less<ll>, rb_tree_tag,tree_order_statistics_node_update> orderedSet;
- #define fastread() (ios_base:: sync_with_stdio(false),cin.tie(NULL));
- #define sf(a) scanf("%I64d",&a)
- #define pf(a) printf("%I64d\n",a)
- #define mem(a,b) memset(a,b,sizeof(a))
- #define vll(v) v.begin(),v.end()
- #define all(x) x.rbegin(),x.rend()
- #define min3(a, b, c) min(a, min(b, c))
- #define F first
- #define S second
- #define minheap int,vector<int>,greater<int>
- #define result(ans) cout<<"Case "<<cas++<<": "<<ans<<endl
- #define pb push_back
- #define pp pop_back
- #define eb emplace_back
- #define in freopen("input.txt", "r", stdin)
- #define out freopen("output.txt", "w", stdout)
- #define BOUNDARY(i, j) ((i >= 0 && i < row) && (j >= 0 && j < column))
- #define ischar(x) (('a' <= x && x <= 'z') || ('A' <= x && x <= 'Z'))
- #define isvowel(ch) ((ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u')||(ch=='A'|| ch=='E' || ch=='I'|| ch=='O'|| ch=='U'))
- const int Max = 2e6 + 10;
- const int Mod = 1e9 + 7;
- const double PI =3.141592653589793238463;
- bool compare(const pair<int,int> &a, const pair<int,int> &b)
- {
- return (a.first > b.first);
- }
- ll lcm(ll a,ll b)
- {
- if(a==0 || b==0)
- return 0;
- return a/__gcd(a,b)*b;
- }
- //___________________________________________________________________________________________________________________
- // CODE STARTS FROM HERE
- // MU_Codefighter2019
- //-------------------------------------------------------------------------------------------------------------------
- ll cnt=0;
- void input(ll ara[],ll n)
- {
- for(int i=1; i<=n; i++)
- cin>>ara[i];
- }
- map<ll,ll>mp;
- void add(ll a)
- {
- if(mp[a]==0)
- cnt++;
- mp[a]++;
- }
- void del(ll a)
- {
- mp[a]--;
- if(mp[a]==0)
- cnt--;
- }
- int main()
- {
- fastread();
- ll t,cas=1,i,j,a,b,c,d,e,sum=0,k,n;
- cin>>n>>k;
- ll ara[n+2];
- map<ll,ll>mp;
- for(i=1; i<=n; i++)
- {
- cin>>ara[i];
- }
- i=1;
- ll pre=1;
- ll mx=0;
- pll ans;
- while(i<=n)
- {
- // cout<<cnt<<endl;
- if(cnt<=k)
- {
- add(ara[i]);
- if(mx<(i-(pre-1)) && cnt<=k)
- {
- ans.F=pre;
- ans.S=i;
- mx=(i-(pre-1));
- // cout<<mx<<endl<<i-(pre-1)<<endl<<endl;
- // cout<<ans.F<<" "<<ans.S<<endl;
- }
- i++;
- }
- else
- {
- del(ara[pre]);
- pre++;
- }
- }
- cout<<ans.F<<" "<<ans.S<<endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement