/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 532.0 KiB
#2 Accepted 1ms 532.0 KiB
#3 Accepted 1ms 384.0 KiB
#4 Accepted 1ms 320.0 KiB
#5 Accepted 1ms 532.0 KiB
#6 Wrong Answer 1ms 540.0 KiB
#7 Accepted 1ms 440.0 KiB
#8 Wrong Answer 1ms 436.0 KiB

Code

#include <bits/stdc++.h>
using namespace std;

#define ll long long int
#define ull unsigned long long
#define vecint vector<int>
#define vecchar vector<char>
#define un_set unordered_set
#define un_map unordered_map
#define max_ele(v) *max_element(v.begin(), v.end())
#define min_ele(v) *min_element(v.begin(), v.end())
#define sort_asc(v) sort(v.begin(), v.end())
#define sort_dec(v) sort((v).begin(), (v).end(), greater<>())
#define Reverse(v) reverse(v.begin(), v.end())
#define pb push_back
#define ppb pop_back()
#define pf push_front
#define coutall(v)     \
    for (auto &it : v) \
    cout << it << " "
#define coutnewline(v) \
    for (auto &it : v) \
    cout << it << '\n'
#define cinall(v)      \
    for (auto &it : v) \
    cin >> it
#define yes cout << "YES\n"
#define no cout << "NO\n"

constexpr char nl = '\n';

void solucionar()
{
    ll n, k;
    cin >> n >> k;
    vecint arr(n), temp(n), error;
    cinall(arr);
    for (int i = 0; i < n; i++)
    {
        temp[i] = i + 1;
    }
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < n; j++)
        {
            if (temp[i] == arr[j])
            {
                if (temp[i] != j + 1)
                {
                    error.pb(j + 1);
                }
            }
            else
            {
                continue;
            }
        }
    }
    sort_asc(error);
    ll last = error.size() - 1;
    if (((error[last] - error[0]) + 1) > k)
    {
        no;
        return;
    }
    else
    {
        yes;
        cout << error[0] << " " << error[error.size() - 1] << endl;
    }
}

int main()
{
    // int tests;
    // cin >> tests;
    // while (tests-- > 0)
    // {
    // }
        solucionar();
    

    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 16:09:16
Judged At
2024-11-05 16:09:16
Judged By
Score
15
Total Time
1ms
Peak Memory
540.0 KiB