/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 540.0 KiB
#2 Accepted 1ms 540.0 KiB
#3 Accepted 1ms 540.0 KiB
#4 Accepted 1ms 540.0 KiB
#5 Accepted 1ms 540.0 KiB
#6 Accepted 1ms 540.0 KiB
#7 Accepted 1ms 328.0 KiB
#8 Accepted 1ms 540.0 KiB
#9 Accepted 1ms 404.0 KiB
#10 Accepted 1ms 540.0 KiB
#11 Accepted 1ms 588.0 KiB
#12 Accepted 2ms 540.0 KiB
#13 Accepted 1ms 540.0 KiB
#14 Accepted 2ms 524.0 KiB
#15 Accepted 2ms 344.0 KiB
#16 Accepted 2ms 540.0 KiB
#17 Accepted 1ms 540.0 KiB
#18 Accepted 2ms 508.0 KiB
#19 Accepted 1ms 540.0 KiB
#20 Accepted 2ms 540.0 KiB
#21 Accepted 3ms 1.027 MiB
#22 Accepted 39ms 5.449 MiB
#23 Accepted 50ms 6.094 MiB
#24 Accepted 49ms 7.77 MiB
#25 Accepted 111ms 11.023 MiB
#26 Accepted 33ms 5.594 MiB
#27 Accepted 6ms 1.566 MiB
#28 Accepted 48ms 6.098 MiB
#29 Accepted 50ms 6.676 MiB
#30 Accepted 70ms 11.27 MiB
#31 Accepted 76ms 8.82 MiB
#32 Accepted 115ms 11.777 MiB
#33 Accepted 63ms 9.621 MiB
#34 Accepted 60ms 7.457 MiB
#35 Accepted 79ms 12.543 MiB

Code

#include<bits/stdc++.h>
#define endl        '\n'
#define F           first
#define S           second
#define pb          push_back
#define yes         cout<<"YES\n"
#define no          cout<<"NO\n"
#define all(x)      x.begin(),x.end()
#define allr(x)     x.rbegin(),x.rend()
#define error1(x)   cerr<<#x<<" = "<<(x)<<endl
#define error2(a,b) cerr<<"("<<#a<<", "<<#b<<") = ("<<(a)<<", "<<(b)<<")\n";
#define coutall(v)  for(auto &it: v) cout << it << " "; cout << endl;
using namespace std;
using ll = long long;
using ld = long double;

void solve() {
    ll n, k;
    cin >> n >> k;
    vector<ll> v(n);
    set<ll> st;
    for (int i = 0; i < n; i++) {
        ll x; cin >> x;
        v[i] = x;
        st.insert(x);
    }
    // if(st.size() < v.size()) {
    //     no;
    //     return;
    // }
    auto tmp = v;
    sort(all(tmp));

    ll l = -1, r = -2;
    for(int i = 0; i < n; i++) {
        if(v[i] != tmp[i]) {
            l = i;
            break;
        }
    }
    for(int i = n - 1; i >= 0; i--) {
        if(v[i] != tmp[i]) {
            r = i;
            break;
        }
    }

    if(l <= r && r - l + 1 <= k) {
        yes;
        cout << l + 1 << " " << r + 1 << endl;
    }
    else no;
    return;
}

signed main() {
    ios::sync_with_stdio(false); cin.tie(0);
    int tc = 1;
    // cin >> tc;
    for (int t = 1; t <= tc; t++) {
        // cout << "Case " << t << ": ";
        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 14:57:27
Judged At
2024-11-05 14:57:27
Judged By
Score
100
Total Time
115ms
Peak Memory
12.543 MiB