/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 532.0 KiB
#2 Accepted 1ms 532.0 KiB
#3 Accepted 1ms 484.0 KiB
#4 Accepted 1ms 484.0 KiB
#5 Accepted 1ms 324.0 KiB
#6 Accepted 1ms 532.0 KiB
#7 Accepted 1ms 484.0 KiB
#8 Wrong Answer 1ms 360.0 KiB
#9 Accepted 1ms 488.0 KiB
#10 Accepted 1ms 340.0 KiB
#11 Accepted 1ms 540.0 KiB
#12 Accepted 1ms 484.0 KiB
#13 Accepted 1ms 484.0 KiB
#14 Accepted 1ms 380.0 KiB
#15 Accepted 1ms 324.0 KiB
#16 Accepted 1ms 376.0 KiB
#17 Accepted 1ms 532.0 KiB
#18 Accepted 1ms 536.0 KiB
#19 Accepted 1ms 532.0 KiB
#20 Accepted 1ms 484.0 KiB
#21 Accepted 4ms 588.0 KiB
#22 Accepted 61ms 1.523 MiB
#23 Accepted 46ms 1.77 MiB
#24 Accepted 53ms 2.27 MiB
#25 Accepted 83ms 3.164 MiB
#26 Accepted 37ms 1.77 MiB
#27 Accepted 8ms 768.0 KiB
#28 Accepted 46ms 1.77 MiB
#29 Accepted 61ms 2.02 MiB
#30 Accepted 102ms 3.133 MiB
#31 Accepted 68ms 2.566 MiB
#32 Accepted 101ms 3.191 MiB
#33 Accepted 66ms 2.668 MiB
#34 Accepted 82ms 2.297 MiB
#35 Accepted 80ms 3.52 MiB

Code

#include <bits/stdc++.h>
using namespace std;
#define ll long long int

void solve()
{
    ll n, k;
    cin >> n>>k;
    vector<ll> v(n);
    
    for(auto &x:v){
        cin>>x;
    }
    vector<ll> s = v;

    if(k >= n){
        cout<<"YES"<<endl;
        cout<<1<<" "<<n<<endl;
        return;
    }
    sort(s.begin(), s.end());
    ll l = -1, r = -1;
    for(int i = 0; i < n; i++){
        if(s[i] != v[i] and l == -1){
            l = i;
        }
        if(s[i] != v[i])r = i;
    }
    if(l == -1){
        cout<<"YES"<<endl;
        cout<<1<<" "<<l<<endl;
        return;
    }
    else{
        ll dif = r - l + 1;
        if(dif > k){
            cout<<"NO"<<endl;
        }
        else{
            cout<<"YES"<<endl;
            cout<<l+1<<" "<<r+1<<endl;
        }

    }



}
int main()
{
    int tc = 1, cs = 1;
    // cin >> tc;
    while (tc--)
    {
        // cout<<"Case "<<cs<<": ";
        solve();
    }
    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 16:15:53
Judged At
2024-11-05 16:15:53
Judged By
Score
97
Total Time
102ms
Peak Memory
3.52 MiB