/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 532.0 KiB
#2 Accepted 1ms 320.0 KiB
#3 Accepted 1ms 532.0 KiB
#4 Accepted 1ms 324.0 KiB
#5 Accepted 1ms 532.0 KiB
#6 Wrong Answer 1ms 532.0 KiB
#7 Accepted 1ms 320.0 KiB
#8 Wrong Answer 1ms 528.0 KiB

Code

// Link ->
// Author -> Efat Sikder, IUBAT
#include "bits/stdc++.h"
using namespace std;

typedef long long int ll;
typedef unsigned long long l1;
typedef double db;

#define pi acos(-1)
#define prDouble(x, y) fixed << setprecision(y) << x
#define lcm(a, b) ((a * b) / __gcd(a, b))
#define fast_io                       \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL)
#define mm(x, v) memset((x), v, sizeof(x));
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define nl << "\n"
#define debug(x) cout << #x << " = " << x nl
#define casePrint(ans, cn) cout << "Case " << cn << ": " << ans nl

void solve(int caseNumber)
{
    ll n, k;
    cin >> n >> k;
    vector<int> ar(n + 1);
    vector<int> br(n + 1);
    for (int i = 1; i <= n; i++)
    {
        cin >> ar[i];
        br[i] = ar[i];
    }
    sort(br.begin(), br.end());
    set<int> st;
    int i = 1;
    bool flag = true;
    pair<int, int> ans = {-1, -1};
    while (i <= n)
    {
        if (ar[i] == br[i])
        {
            i++;
            continue;
        }
        for (int j = i; j < min(i + k, n + 1); j++)
        {
            st.insert(ar[j]);
        }
        for (int j = i; j < min(i + k, n + 1); j++)
        {
            if (st.find(br[j]) == st.end())
            {
                cout << "NO" nl;
                return;
            }
        }
        if (ans.first == -1)
            ans.first = i, ans.second = i + k - 1;
        i += k;
    }
    cout << "YES" nl;
    cout << ans.first << " " << ans.second nl;
}

void init_code()
{
    fast_io;
}

signed main()
{
    init_code();
    int testcase = 1;
    // cin >> testcase;
    for (int caseNumber = 1; caseNumber <= testcase; ++caseNumber)
    {
        solve(caseNumber);
    }
    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:15:44
Judged At
2024-11-05 15:15:44
Judged By
Score
15
Total Time
1ms
Peak Memory
532.0 KiB