/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 540.0 KiB
#2 Accepted 1ms 540.0 KiB
#3 Accepted 1ms 640.0 KiB
#4 Accepted 1ms 616.0 KiB
#5 Accepted 1ms 540.0 KiB
#6 Accepted 1ms 540.0 KiB
#7 Accepted 1ms 348.0 KiB
#8 Accepted 1ms 540.0 KiB
#9 Accepted 2ms 332.0 KiB
#10 Accepted 1ms 328.0 KiB
#11 Accepted 1ms 332.0 KiB
#12 Accepted 2ms 488.0 KiB
#13 Accepted 1ms 332.0 KiB
#14 Accepted 1ms 540.0 KiB
#15 Accepted 1ms 772.0 KiB
#16 Accepted 1ms 540.0 KiB
#17 Accepted 2ms 356.0 KiB
#18 Accepted 1ms 356.0 KiB
#19 Accepted 2ms 492.0 KiB
#20 Accepted 1ms 540.0 KiB
#21 Accepted 6ms 980.0 KiB
#22 Accepted 75ms 6.52 MiB
#23 Accepted 78ms 7.438 MiB
#24 Accepted 146ms 9.277 MiB
#25 Accepted 235ms 13.688 MiB
#26 Accepted 59ms 7.066 MiB
#27 Accepted 11ms 1.562 MiB
#28 Accepted 94ms 7.461 MiB
#29 Accepted 94ms 8.324 MiB
#30 Accepted 124ms 14.078 MiB
#31 Accepted 140ms 10.867 MiB
#32 Accepted 136ms 14.609 MiB
#33 Accepted 104ms 11.77 MiB
#34 Accepted 111ms 9.551 MiB
#35 Accepted 135ms 15.672 MiB

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