/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 532.0 KiB
#2 Wrong Answer 1ms 340.0 KiB
#3 Accepted 1ms 420.0 KiB
#4 Accepted 1ms 532.0 KiB
#5 Accepted 1ms 528.0 KiB
#6 Accepted 1ms 436.0 KiB
#7 Accepted 1ms 484.0 KiB
#8 Accepted 1ms 532.0 KiB
#9 Accepted 1ms 532.0 KiB
#10 Wrong Answer 1ms 532.0 KiB

Code

/*
 *Copyright (c) Swadheen Islam Robi (SIR01)
 *Created on Tue Nov 05 2024 9:14:06 PM
 */
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pie 2*(acos(0.0))
#define yes cout<<"YES\n"
#define no cout<<"NO\n"
#define pb push_back
#define endl "\n"
#define lcm(a,b) (a*b)/(__gcd<ll>(a,b))
#define mod 1000000007
#define srt(v) sort(v.begin(),v.end())
#define rsrt(v) sort(v.rbegin(),v.rend())
#define ALLAHU_AKBAR ios::sync_with_stdio(false); cin.tie(nullptr);

void sir2()
{
    // int y
    ll n,k; cin>>n>>k;
    vector<ll>a(n);
    for(ll i=0; i<n; i++)cin>>a[i];

    ll sc =0;
    ll cnt=1;
    ll st, en;
    //bool ok = false;
    ll chk =0;
    for(ll i=0; i<n-1; i++)
    {
        if(a[i]>a[i+1]){
            sc++;
            ll key = a[i];
            if(i !=0) chk = a[i-1];
            
            st = i;
            i++;
            
            while(1)
            {
                if(key>a[i]){
                    cnt++;
                en = i;
                //if(a[i]<chk) ok = true;
                i++;
                }
                else {
                    i--;
                    break;
                }
                
            }

        }
    }
    if(sc>1 || cnt>k || cnt==1) cout<<"NO"<<endl;
    else{
        cout<<"YES"<<endl;
        cout<<st+1<<" "<<en+1<<endl;
        //cout<<sc<<" "<<cnt;
    }
    
}
void sir()
{
    ll n, k; cin>>n>>k;
    vector<ll>a(n), b(n);
    for(ll i=0; i<n; i++)
    {
        cin>>a[i];
        b[i] = a[i];
    }
    srt(b);
    ll st,end;
    for(ll i=0; i<n; i++)
    {
        if(a[i] != b[i]) {st = i;
         break;}
    }
    for(ll i=n-1; i>=0; i--)
    {
        if(a[i] != b[i]) {end = i; break;}
    }
    if(end-st>k) cout<<"NO"<<endl;
    else{
        cout<<"YES"<<endl;
        cout<<st+1<<" "<<end+1<<endl;
    }
}

int main() {
    ALLAHU_AKBAR

    ll t = 1;
    //cin>>t;
    while(t--)
    {
        sir();
    }
    return 0;
}

Information

Submit By
Type
Submission
Problem
P1120 Stairway to the Skyline
Language
C++17 (G++ 13.2.0)
Submit At
2024-11-05 17:15:58
Judged At
2024-11-05 17:15:58
Judged By
Score
22
Total Time
1ms
Peak Memory
532.0 KiB