/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 532.0 KiB
#2 Accepted 1ms 532.0 KiB
#3 Accepted 1ms 532.0 KiB
#4 Accepted 1ms 488.0 KiB
#5 Accepted 1ms 340.0 KiB
#6 Accepted 1ms 488.0 KiB
#7 Accepted 1ms 532.0 KiB
#8 Accepted 1ms 532.0 KiB
#9 Accepted 1ms 520.0 KiB
#10 Accepted 1ms 388.0 KiB
#11 Accepted 1ms 532.0 KiB
#12 Accepted 1ms 320.0 KiB
#13 Accepted 1ms 324.0 KiB
#14 Accepted 1ms 532.0 KiB
#15 Accepted 1ms 532.0 KiB
#16 Accepted 1ms 480.0 KiB
#17 Accepted 1ms 520.0 KiB
#18 Accepted 1ms 384.0 KiB
#19 Accepted 1ms 532.0 KiB
#20 Accepted 1ms 532.0 KiB
#21 Accepted 2ms 532.0 KiB
#22 Accepted 16ms 1.77 MiB
#23 Accepted 16ms 1.77 MiB
#24 Accepted 17ms 2.27 MiB
#25 Accepted 58ms 3.0 MiB
#26 Accepted 11ms 1.77 MiB
#27 Accepted 3ms 788.0 KiB
#28 Accepted 25ms 1.773 MiB
#29 Accepted 19ms 2.02 MiB
#30 Accepted 47ms 3.258 MiB
#31 Accepted 26ms 2.52 MiB
#32 Accepted 25ms 3.27 MiB
#33 Accepted 21ms 2.77 MiB
#34 Accepted 20ms 2.07 MiB
#35 Accepted 26ms 3.566 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-05 14:53:36
Judged By
Score
100
Total Time
58ms
Peak Memory
3.566 MiB