/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 540.0 KiB
#2 Accepted 1ms 520.0 KiB
#3 Accepted 1ms 540.0 KiB
#4 Accepted 1ms 540.0 KiB
#5 Accepted 1ms 768.0 KiB
#6 Accepted 2ms 376.0 KiB
#7 Accepted 1ms 540.0 KiB
#8 Accepted 1ms 772.0 KiB
#9 Accepted 1ms 332.0 KiB
#10 Accepted 2ms 516.0 KiB
#11 Accepted 2ms 532.0 KiB
#12 Accepted 2ms 516.0 KiB
#13 Accepted 1ms 744.0 KiB
#14 Accepted 2ms 492.0 KiB
#15 Accepted 1ms 540.0 KiB
#16 Accepted 2ms 512.0 KiB
#17 Accepted 1ms 324.0 KiB
#18 Accepted 1ms 392.0 KiB
#19 Accepted 1ms 516.0 KiB
#20 Accepted 2ms 512.0 KiB
#21 Accepted 2ms 796.0 KiB
#22 Accepted 11ms 1.379 MiB
#23 Accepted 12ms 1.668 MiB
#24 Accepted 14ms 2.145 MiB
#25 Accepted 28ms 2.504 MiB
#26 Accepted 11ms 1.449 MiB
#27 Accepted 3ms 540.0 KiB
#28 Accepted 13ms 1.855 MiB
#29 Accepted 13ms 1.645 MiB
#30 Accepted 22ms 2.695 MiB
#31 Accepted 17ms 2.258 MiB
#32 Accepted 22ms 2.902 MiB
#33 Accepted 18ms 2.156 MiB
#34 Accepted 14ms 1.809 MiB
#35 Accepted 24ms 2.758 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-05 15:27:05
Judged By
Score
100
Total Time
28ms
Peak Memory
2.902 MiB