/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 324.0 KiB
#2 Accepted 1ms 320.0 KiB
#3 Accepted 1ms 324.0 KiB
#4 Accepted 1ms 484.0 KiB
#5 Accepted 1ms 372.0 KiB
#6 Accepted 1ms 504.0 KiB
#7 Accepted 1ms 324.0 KiB
#8 Accepted 1ms 532.0 KiB
#9 Accepted 1ms 536.0 KiB
#10 Accepted 1ms 532.0 KiB
#11 Accepted 1ms 328.0 KiB
#12 Accepted 1ms 532.0 KiB
#13 Accepted 1ms 376.0 KiB
#14 Accepted 1ms 488.0 KiB
#15 Accepted 1ms 532.0 KiB
#16 Accepted 1ms 496.0 KiB
#17 Accepted 1ms 536.0 KiB
#18 Accepted 1ms 492.0 KiB
#19 Accepted 1ms 324.0 KiB
#20 Accepted 1ms 324.0 KiB
#21 Accepted 2ms 516.0 KiB
#22 Accepted 16ms 1.672 MiB
#23 Accepted 16ms 1.762 MiB
#24 Accepted 18ms 2.184 MiB
#25 Accepted 34ms 3.184 MiB
#26 Accepted 12ms 1.699 MiB
#27 Accepted 3ms 788.0 KiB
#28 Accepted 19ms 1.973 MiB
#29 Accepted 19ms 2.062 MiB
#30 Accepted 24ms 3.168 MiB
#31 Accepted 27ms 2.625 MiB
#32 Accepted 26ms 3.211 MiB
#33 Accepted 20ms 2.688 MiB
#34 Accepted 23ms 2.18 MiB
#35 Accepted 26ms 3.578 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-11 02:32:13
Judged By
Score
100
Total Time
34ms
Peak Memory
3.578 MiB