/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 392.0 KiB
#2 Accepted 1ms 532.0 KiB
#3 Wrong Answer 1ms 532.0 KiB
#4 Wrong Answer 1ms 364.0 KiB

Code

#include <bits/stdc++.h>
#define ll long long
#define pub push_back
#define fast                      \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);
using namespace std;
void solve()
{
    int n, k;
    cin >> n >> k;
    int a[n], b[n];
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        b[i] = a[i];
    }
    sort(b, b + n);
    int cnt = 0, ans = 0;
    int ansA = -1, ansB = -1;
    for (int i = 0; i < n; i++)
    {
        if (a[i] != b[i])
        {
            cnt++;
            if (ansA == -1)
                ansA = i;
        }
        else
        {
            if (ansB == -1 && ansA != -1)
                ansB = i - 1;
            ans = max(ans, cnt);
            cnt = 0;
        }
    }
    ans = max(ans, cnt);
    if (ans <= k)
    {
        cout << "YES" << endl;
        cout << ansA + 1 << " " << ansB + 1 << endl;
    }
    else
    {
        cout << "NO" << endl;
    }
}
int main()
{
    fast;
    ll 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 14:52:09
Judged At
2024-11-05 14:52:09
Judged By
Score
4
Total Time
1ms
Peak Memory
532.0 KiB