/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 532.0 KiB
#2 Accepted 1ms 324.0 KiB
#3 Accepted 1ms 320.0 KiB
#4 Accepted 1ms 532.0 KiB
#5 Accepted 1ms 532.0 KiB
#6 Accepted 1ms 532.0 KiB
#7 Accepted 1ms 532.0 KiB
#8 Accepted 1ms 532.0 KiB
#9 Accepted 1ms 532.0 KiB
#10 Accepted 1ms 488.0 KiB
#11 Accepted 1ms 316.0 KiB
#12 Accepted 2ms 532.0 KiB
#13 Accepted 2ms 480.0 KiB
#14 Accepted 2ms 500.0 KiB
#15 Accepted 2ms 532.0 KiB
#16 Accepted 2ms 408.0 KiB
#17 Accepted 2ms 532.0 KiB
#18 Accepted 2ms 532.0 KiB
#19 Accepted 4ms 320.0 KiB
#20 Accepted 4ms 532.0 KiB
#21 Accepted 13ms 532.0 KiB
#22 Accepted 66ms 1.023 MiB
#23 Accepted 71ms 1.02 MiB
#24 Accepted 53ms 1.27 MiB
#25 Accepted 88ms 1.77 MiB
#26 Accepted 37ms 1.02 MiB
#27 Accepted 8ms 580.0 KiB
#28 Accepted 50ms 1.062 MiB
#29 Accepted 79ms 1.062 MiB
#30 Accepted 80ms 1.887 MiB
#31 Accepted 68ms 1.52 MiB
#32 Accepted 97ms 1.77 MiB
#33 Accepted 65ms 1.52 MiB
#34 Accepted 58ms 1.27 MiB
#35 Accepted 109ms 1.906 MiB

Code

#include<bits/stdc++.h>
using namespace std; 
char nl = '\n';
using i64 = long long;

void solve(int t) {
    // cout << "test #" << t << nl;
    int n, k; cin >> n >> k;
    vector<pair<int, int>> A(n);
    for (int i = 0; i < n; i++) {
        cin >> A[i].first;
        A[i].second = i;
    } 
    sort(A.begin(), A.end());
    int mx = -1, mn = n;
    for (int i = 0; i < n; i++) {
        if (A[i].second != i) {
            mx = max(mx, i);
            mn = min(mn, i);
        }
    }
    if (mx - mn + 1 <= k) {
        cout << "YES" << nl;
        cout << mn + 1 << " " << mx + 1 << nl;
    } else {
        cout << "NO" << nl;
    }
} 

int main() {
    int tt = 1;
    // cin >> tt;
    for(int t = 1; t <= tt; t++) solve(t);
}

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:59:14
Judged At
2024-11-05 14:59:14
Judged By
Score
100
Total Time
109ms
Peak Memory
1.906 MiB