/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 532.0 KiB
#2 Accepted 1ms 408.0 KiB
#3 Accepted 1ms 480.0 KiB
#4 Accepted 1ms 536.0 KiB
#5 Accepted 1ms 532.0 KiB
#6 Accepted 1ms 532.0 KiB
#7 Accepted 1ms 532.0 KiB
#8 Accepted 1ms 352.0 KiB
#9 Accepted 1ms 536.0 KiB
#10 Accepted 1ms 320.0 KiB
#11 Accepted 1ms 536.0 KiB
#12 Accepted 1ms 560.0 KiB
#13 Accepted 1ms 484.0 KiB
#14 Accepted 1ms 508.0 KiB
#15 Accepted 1ms 336.0 KiB
#16 Accepted 1ms 320.0 KiB
#17 Accepted 1ms 532.0 KiB
#18 Accepted 1ms 320.0 KiB
#19 Accepted 1ms 532.0 KiB
#20 Accepted 1ms 488.0 KiB
#21 Accepted 2ms 584.0 KiB
#22 Accepted 14ms 1.02 MiB
#23 Accepted 15ms 1.023 MiB
#24 Accepted 17ms 1.273 MiB
#25 Accepted 32ms 1.867 MiB
#26 Accepted 11ms 1.195 MiB
#27 Accepted 3ms 444.0 KiB
#28 Accepted 18ms 1.02 MiB
#29 Accepted 18ms 1.332 MiB
#30 Accepted 21ms 1.77 MiB
#31 Accepted 24ms 1.52 MiB
#32 Accepted 24ms 1.77 MiB
#33 Accepted 18ms 1.562 MiB
#34 Accepted 21ms 1.43 MiB
#35 Accepted 23ms 2.02 MiB

Code

// Created on: 2024-11-05 20:16
// Author: Safwan_Ibrahim

#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define endl '\n'

void solve()
{
    int n,k; cin >> n >> k;
    int a[n + 1], b[n + 1];
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        b[i] = a[i];
    }

    sort(b + 1, b + n + 1);
    int l = 0,r = 0;
    for (int i = 1; i <= n; i++) {
        if (a[i] != b[i]) {
            l = i;
            break;
        }
    }
    for (int i = n; i >= 1; i--) {
        if (a[i] != b[i]) {
            r = i;
            break;
        }
    }

    if(l) {
        if (r - l + 1 <= k) {
            cout << "YES\n";
            cout << l << " " << r << endl;
            return;
        } 
    }
    cout << "NO\n";
    
}

int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int t = 1;
    while(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 15:10:01
Judged At
2024-11-05 15:10:01
Judged By
Score
100
Total Time
32ms
Peak Memory
2.02 MiB