/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 2ms 532.0 KiB
#2 Accepted 2ms 348.0 KiB
#3 Accepted 4ms 444.0 KiB
#4 Accepted 4ms 352.0 KiB
#5 Accepted 4ms 532.0 KiB
#6 Accepted 4ms 536.0 KiB
#7 Accepted 5ms 504.0 KiB
#8 Accepted 4ms 532.0 KiB
#9 Accepted 4ms 532.0 KiB
#10 Accepted 5ms 380.0 KiB
#11 Accepted 5ms 764.0 KiB
#12 Accepted 4ms 532.0 KiB
#13 Accepted 4ms 440.0 KiB
#14 Accepted 4ms 532.0 KiB
#15 Accepted 4ms 536.0 KiB
#16 Accepted 4ms 532.0 KiB
#17 Accepted 4ms 324.0 KiB
#18 Accepted 5ms 372.0 KiB
#19 Accepted 4ms 532.0 KiB
#20 Accepted 4ms 532.0 KiB
#21 Accepted 7ms 584.0 KiB
#22 Accepted 32ms 1.566 MiB
#23 Accepted 17ms 1.77 MiB
#24 Accepted 38ms 2.082 MiB
#25 Accepted 33ms 3.02 MiB
#26 Accepted 11ms 1.77 MiB
#27 Accepted 4ms 680.0 KiB
#28 Accepted 27ms 1.77 MiB
#29 Accepted 20ms 2.09 MiB
#30 Accepted 23ms 3.02 MiB
#31 Accepted 30ms 2.602 MiB
#32 Accepted 44ms 3.27 MiB
#33 Accepted 19ms 2.77 MiB
#34 Accepted 28ms 2.18 MiB
#35 Accepted 49ms 3.52 MiB

Code

#ifndef LOCAL
#include <bits/stdc++.h>
#define debug(...)
#endif

using namespace std;
#define int long long
#define cinv(v) for (auto &it:v) cin>>it;
#define coutv(v) for (auto &it:v) cout<< it<<' '; cout<<'\n';

void shelby() {
    int n, k;
    cin >> n >> k;
    vector<int> v(n + 1);
    for (int i = 1; i <= n; ++i) cin >> v[i];
    vector<int> tmp = v;
    sort(v.begin(), v.end());
    if (v == tmp) {
        cout << "1 1\n";
        return;
    }
    int l, r;
    for (int i = 1; i <= n; ++i) {
        if (v[i] != tmp[i]) {
            l = i;
            break;
        }
    }
    for (int i = n; i > 0; --i) {
        if (v[i] != tmp[i]) {
            r = i;
            break;
        }
    }
    if (r - l + 1 <= k) cout << "YES\n" << l << ' ' << r << '\n';
    else cout << "NO\n";
}

signed main() {
    cin.tie(0)->sync_with_stdio(0);
    int t = 1;
    // cin >> t;
    for (int _ = 1; _ <= t; ++_) {
        // cout << "Case " << _ << ": ";
        shelby();
    }
}

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