/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 320.0 KiB
#2 Accepted 1ms 532.0 KiB
#3 Accepted 1ms 532.0 KiB
#4 Accepted 1ms 532.0 KiB
#5 Accepted 1ms 532.0 KiB
#6 Accepted 1ms 532.0 KiB
#7 Accepted 1ms 320.0 KiB
#8 Accepted 1ms 320.0 KiB
#9 Accepted 1ms 320.0 KiB
#10 Accepted 1ms 532.0 KiB
#11 Accepted 1ms 532.0 KiB
#12 Accepted 1ms 532.0 KiB
#13 Accepted 1ms 320.0 KiB
#14 Accepted 1ms 320.0 KiB
#15 Accepted 1ms 324.0 KiB
#16 Accepted 1ms 504.0 KiB
#17 Accepted 1ms 324.0 KiB
#18 Accepted 1ms 320.0 KiB
#19 Accepted 1ms 320.0 KiB
#20 Accepted 1ms 320.0 KiB
#21 Accepted 6ms 832.0 KiB
#22 Accepted 91ms 6.629 MiB
#23 Accepted 94ms 7.445 MiB
#24 Accepted 101ms 9.18 MiB
#25 Accepted 218ms 13.723 MiB
#26 Accepted 66ms 7.004 MiB
#27 Accepted 12ms 1.586 MiB
#28 Accepted 113ms 7.52 MiB
#29 Accepted 115ms 8.387 MiB
#30 Accepted 134ms 14.102 MiB
#31 Accepted 162ms 10.926 MiB
#32 Accepted 147ms 14.633 MiB
#33 Accepted 112ms 11.84 MiB
#34 Accepted 134ms 9.102 MiB
#35 Accepted 147ms 15.59 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-11 02:31:58
Judged By
Score
100
Total Time
218ms
Peak Memory
15.59 MiB