/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 324.0 KiB
#2 Accepted 1ms 324.0 KiB
#3 Accepted 1ms 324.0 KiB
#4 Accepted 1ms 324.0 KiB
#5 Accepted 1ms 324.0 KiB
#6 Accepted 1ms 532.0 KiB
#7 Accepted 1ms 324.0 KiB
#8 Accepted 1ms 324.0 KiB
#9 Accepted 1ms 320.0 KiB
#10 Accepted 1ms 320.0 KiB
#11 Accepted 1ms 324.0 KiB
#12 Accepted 1ms 324.0 KiB
#13 Accepted 1ms 536.0 KiB
#14 Accepted 1ms 324.0 KiB
#15 Accepted 1ms 320.0 KiB
#16 Accepted 1ms 324.0 KiB
#17 Accepted 1ms 536.0 KiB
#18 Accepted 1ms 520.0 KiB
#19 Accepted 1ms 320.0 KiB
#20 Accepted 1ms 436.0 KiB
#21 Accepted 2ms 576.0 KiB
#22 Accepted 11ms 1.484 MiB
#23 Accepted 12ms 1.562 MiB
#24 Accepted 15ms 1.906 MiB
#25 Accepted 22ms 2.652 MiB
#26 Accepted 12ms 1.652 MiB
#27 Accepted 3ms 576.0 KiB
#28 Accepted 13ms 1.656 MiB
#29 Accepted 14ms 1.617 MiB
#30 Accepted 22ms 2.496 MiB
#31 Accepted 18ms 2.172 MiB
#32 Accepted 23ms 2.68 MiB
#33 Accepted 19ms 2.184 MiB
#34 Accepted 16ms 2.0 MiB
#35 Accepted 25ms 2.863 MiB

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;
    vector<int> nums;
    for (int i = 1; i <= n; i++)
    {
        int x;
        cin >> x;
        nums.push_back(x);
    }
    vector<int> l(n), r(n);
    int mn = 1e9, mx = -1e9;

    for (int i = 0; i < n; i++)
    {
        mx = max(mx, nums[i]);
        l[i] = mx;

        mn = min(mn, nums[n - i - 1]);
        r[n - i - 1] = mn;
    }

    int s = -1, e = -1;
    for (int i = 0; i < n; i++)
    {
        if (l[i] > r[i] && s == -1)
            s = i;
        if (l[n - i - 1] > r[n - i - 1] && e == -1)
            e = n - i - 1;
    }
    if (e - s + 1 > k)
        cout << "NO" << endl;
    else
    {
        cout << "YES" << endl;
        cout << s + 1 << " " << e + 1 << 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 15:27:05
Judged At
2024-11-11 02:30:41
Judged By
Score
100
Total Time
25ms
Peak Memory
2.863 MiB