/ 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 532.0 KiB
#4 Wrong Answer 1ms 532.0 KiB
#5 Accepted 1ms 536.0 KiB
#6 Wrong Answer 1ms 532.0 KiB

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);
    map<ll, ll> mp;
    for(auto &x:v){
        cin>>x;
        mp[x]++;
    }
    vector<ll> s = v;

    if(mp.size() < n){
        cout<<"NO"<<endl;
        return;
    }
    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:10:04
Judged At
2024-11-05 16:10:04
Judged By
Score
9
Total Time
1ms
Peak Memory
536.0 KiB