Accepted
Code
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
ll n,k;
cin>>n>>k;
vector<ll>v(n),p;
map<ll,ll>mp;
for(int i=0;i<n;i++)
{
cin>>v[i];
mp[v[i]]=i;
}
p=v;
sort(p.begin(),p.end());
ll c=0;
ll mn,mx=0;
for(int i=0;i<n;i++)
{
if(p[i]!=v[i])
{
c++;
if(c==1)
mn=i+1;
mx=i+1;
}
}
if((mx-mn)+1<=k)
{
cout<<"YES\n";
cout<<mn<<" "<<mx<<endl;
}
else
cout<<"NO\n";
}
Information
- Submit By
- Type
- Submission
- Problem
- P1120 Stairway to the Skyline
- Contest
- Brain Booster #7
- Language
- C++17 (G++ 13.2.0)
- Submit At
- 2024-11-05 14:57:34
- Judged At
- 2024-11-05 14:57:34
- Judged By
- Score
- 100
- Total Time
- 235ms
- Peak Memory
- 15.672 MiB