/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 2ms 484.0 KiB
#2 Accepted 2ms 508.0 KiB
#3 Accepted 2ms 332.0 KiB
#4 Accepted 2ms 328.0 KiB
#5 Accepted 2ms 528.0 KiB
#6 Accepted 2ms 332.0 KiB
#7 Accepted 2ms 492.0 KiB
#8 Accepted 2ms 540.0 KiB
#9 Accepted 2ms 540.0 KiB
#10 Accepted 2ms 540.0 KiB
#11 Accepted 2ms 500.0 KiB
#12 Accepted 2ms 540.0 KiB
#13 Accepted 2ms 540.0 KiB
#14 Accepted 2ms 352.0 KiB
#15 Accepted 2ms 332.0 KiB
#16 Accepted 2ms 332.0 KiB
#17 Accepted 2ms 328.0 KiB
#18 Accepted 2ms 520.0 KiB
#19 Accepted 2ms 504.0 KiB
#20 Accepted 2ms 496.0 KiB
#21 Accepted 3ms 584.0 KiB
#22 Accepted 23ms 1.16 MiB
#23 Accepted 25ms 1.25 MiB
#24 Accepted 28ms 1.422 MiB
#25 Accepted 48ms 1.867 MiB
#26 Accepted 20ms 1.199 MiB
#27 Accepted 5ms 676.0 KiB
#28 Accepted 27ms 1.254 MiB
#29 Accepted 28ms 1.324 MiB
#30 Accepted 39ms 1.898 MiB
#31 Accepted 38ms 1.578 MiB
#32 Accepted 43ms 1.957 MiB
#33 Accepted 33ms 1.68 MiB
#34 Accepted 33ms 1.273 MiB
#35 Accepted 43ms 2.07 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-11 02:31:21
Judged By
Score
100
Total Time
48ms
Peak Memory
2.07 MiB