/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 532.0 KiB
#2 Accepted 1ms 520.0 KiB
#3 Accepted 1ms 324.0 KiB
#4 Accepted 1ms 532.0 KiB
#5 Accepted 1ms 480.0 KiB
#6 Accepted 1ms 536.0 KiB
#7 Accepted 1ms 364.0 KiB
#8 Accepted 1ms 320.0 KiB
#9 Accepted 1ms 532.0 KiB
#10 Accepted 1ms 764.0 KiB
#11 Accepted 1ms 320.0 KiB
#12 Accepted 1ms 320.0 KiB
#13 Accepted 1ms 440.0 KiB
#14 Accepted 1ms 324.0 KiB
#15 Accepted 1ms 356.0 KiB
#16 Accepted 1ms 320.0 KiB
#17 Accepted 1ms 320.0 KiB
#18 Accepted 1ms 324.0 KiB
#19 Accepted 1ms 484.0 KiB
#20 Accepted 1ms 320.0 KiB
#21 Accepted 2ms 564.0 KiB
#22 Accepted 16ms 1.773 MiB
#23 Accepted 16ms 1.812 MiB
#24 Accepted 18ms 2.305 MiB
#25 Accepted 33ms 3.184 MiB
#26 Accepted 12ms 1.852 MiB
#27 Accepted 3ms 684.0 KiB
#28 Accepted 19ms 1.836 MiB
#29 Accepted 19ms 2.113 MiB
#30 Accepted 23ms 3.254 MiB
#31 Accepted 27ms 2.625 MiB
#32 Accepted 26ms 3.375 MiB
#33 Accepted 20ms 2.828 MiB
#34 Accepted 23ms 2.301 MiB
#35 Accepted 26ms 3.598 MiB

Code

#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define ll long long int
#define N (ll)1e6
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t=1,i=1,j,p,mx,tot,n,a,m,x,y,k,rt,c,b=1;
    //cin>>t;
    while(t--){
        cin>>n>>k;
        ll ar[n],br[n];
        for(a=0;a<n;a++){
            cin>>ar[a];
            br[a]=ar[a];
        }
        sort(ar,ar+n);
        for(a=0;a<n;a++){
            if(ar[a]!=br[a]){
                i=a;
                break;
            }
        }
        for(a=n-1;a>=0;a--){
            if(ar[a]!=br[a]){
                j=a;
                break;
            }
        }
        if(j-i+1<=k){
            cout<<"YES\n";
            cout<<i+1<<' '<<j+1<<endl;
        }
        else
            cout<<"NO\n";
    }
}

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 14:53:36
Judged At
2024-11-11 02:32:13
Judged By
Score
100
Total Time
33ms
Peak Memory
3.598 MiB