/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Wrong Answer 1ms 328.0 KiB
#2 Accepted 1ms 324.0 KiB
#3 Accepted 1ms 324.0 KiB
#4 Wrong Answer 1ms 356.0 KiB

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);
        }
    }
    cout << (mx - mn + 1 <= k ? "YES" : "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:55:26
Judged At
2024-11-11 02:32:06
Judged By
Score
4
Total Time
1ms
Peak Memory
356.0 KiB