/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 532.0 KiB
#2 Accepted 1ms 536.0 KiB
#3 Accepted 1ms 536.0 KiB
#4 Accepted 1ms 532.0 KiB
#5 Accepted 1ms 532.0 KiB
#6 Accepted 1ms 536.0 KiB
#7 Accepted 1ms 476.0 KiB
#8 Accepted 1ms 484.0 KiB
#9 Accepted 1ms 532.0 KiB
#10 Accepted 1ms 532.0 KiB
#11 Accepted 1ms 528.0 KiB
#12 Accepted 1ms 496.0 KiB
#13 Accepted 1ms 532.0 KiB
#14 Accepted 1ms 532.0 KiB
#15 Accepted 1ms 532.0 KiB
#16 Accepted 1ms 520.0 KiB
#17 Accepted 1ms 532.0 KiB
#18 Accepted 1ms 532.0 KiB
#19 Accepted 1ms 320.0 KiB
#20 Accepted 1ms 532.0 KiB
#21 Accepted 2ms 532.0 KiB
#22 Accepted 16ms 1.668 MiB
#23 Accepted 18ms 1.77 MiB
#24 Accepted 23ms 2.27 MiB
#25 Accepted 33ms 3.125 MiB
#26 Accepted 12ms 1.77 MiB
#27 Accepted 3ms 920.0 KiB
#28 Accepted 22ms 1.766 MiB
#29 Accepted 23ms 2.02 MiB
#30 Accepted 45ms 3.02 MiB
#31 Accepted 25ms 2.52 MiB
#32 Accepted 25ms 3.215 MiB
#33 Accepted 42ms 2.77 MiB
#34 Accepted 21ms 2.27 MiB
#35 Accepted 25ms 3.52 MiB

Code

#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl "\n"
#define ff first
#define ss second
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define f(i,x,y) for(int i=x;i<y;i++)
#define f2(i,x,y) for(int i=x;i>=y;i--)
#define pii pair<int,int>
#define Fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const int MOD =1000000007;
const int INF = 1e18;
const int N = 2e5;
 
void solve(int tc){
    int n,k; cin >> n >> k;
    vector<int>v(n),s; for(int i=0;i<n;i++)cin >> v[i];
    s=v;
    sort(all(v));
    int l = n , r = -1;
    for(int i=0;i<n;i++){
        if(v[i]==s[i])continue;
        l = min(l,i);
        r = max(r,i);
    }
    if(l>r){
        cout << "YES" << endl;
        cout << 1 << " " << 1 << endl;
    }
    else if(r-l+1>k)cout << "NO" << endl;
    else {
        cout << "YES" << endl;
        cout << l+1 << " " << r+1 << endl;
    }
}
int32_t main(){

    Fast

    int t=1;

    //cin >> t;

    for(int tc=1;tc<=t;tc++){

        solve(tc);
    }
    return 0;
}

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 15:08:53
Judged At
2024-11-05 15:08:53
Judged By
Score
100
Total Time
45ms
Peak Memory
3.52 MiB