/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 736.0 KiB
#2 Accepted 1ms 332.0 KiB
#3 Accepted 1ms 556.0 KiB
#4 Wrong Answer 2ms 596.0 KiB
#5 Accepted 2ms 332.0 KiB
#6 Wrong Answer 1ms 328.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];
    map<int, int> idx;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        b[i] = a[i];
        idx[a[i]] = i;
    }
    sort(b, b + n);
    for (int i = 0; i < n; i++)
    {
        if (abs(idx[b[i]] - i) + 1 > k)
        {
            cout << "NO" << endl;
            return;
        }
    }
    cout << "YES" << endl;
    for (int i = 0; i < n; i++)
    {
        if (a[i] != b[i])
        {
            cout << min(idx[a[i]], idx[b[i]]) + 1 << " " << max(idx[a[i]], idx[b[i]]) + 1 << endl;
            return;
        }
    }
}
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:06:29
Judged At
2024-11-05 15:06:29
Judged By
Score
9
Total Time
2ms
Peak Memory
736.0 KiB