/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 3ms 540.0 KiB
#2 Accepted 2ms 328.0 KiB
#3 Accepted 2ms 328.0 KiB
#4 Accepted 2ms 332.0 KiB
#5 Accepted 2ms 456.0 KiB
#6 Accepted 2ms 356.0 KiB
#7 Accepted 2ms 716.0 KiB
#8 Accepted 2ms 492.0 KiB
#9 Accepted 2ms 328.0 KiB
#10 Accepted 2ms 328.0 KiB
#11 Accepted 2ms 332.0 KiB
#12 Accepted 2ms 584.0 KiB
#13 Accepted 2ms 568.0 KiB
#14 Accepted 2ms 328.0 KiB
#15 Accepted 2ms 336.0 KiB
#16 Accepted 2ms 528.0 KiB
#17 Accepted 3ms 544.0 KiB
#18 Accepted 2ms 332.0 KiB
#19 Accepted 2ms 508.0 KiB
#20 Accepted 2ms 492.0 KiB
#21 Accepted 8ms 584.0 KiB
#22 Accepted 73ms 1.141 MiB
#23 Accepted 76ms 1.234 MiB
#24 Accepted 99ms 1.406 MiB
#25 Accepted 154ms 1.852 MiB
#26 Accepted 74ms 1.168 MiB
#27 Accepted 14ms 648.0 KiB
#28 Accepted 83ms 1.23 MiB
#29 Accepted 87ms 1.309 MiB
#30 Accepted 142ms 1.887 MiB
#31 Accepted 119ms 1.566 MiB
#32 Accepted 154ms 1.938 MiB
#33 Accepted 130ms 1.664 MiB
#34 Accepted 99ms 1.402 MiB
#35 Accepted 160ms 2.055 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-11 02:31:53
Judged By
Score
100
Total Time
160ms
Peak Memory
2.055 MiB