/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 8ms 7.238 MiB
#2 Accepted 6ms 7.398 MiB
#3 Accepted 7ms 7.371 MiB
#4 Accepted 6ms 7.527 MiB
#5 Accepted 7ms 7.285 MiB
#6 Accepted 6ms 7.215 MiB
#7 Accepted 7ms 7.344 MiB
#8 Accepted 6ms 7.316 MiB
#9 Accepted 7ms 7.184 MiB
#10 Accepted 7ms 7.332 MiB
#11 Accepted 7ms 7.52 MiB
#12 Accepted 8ms 7.32 MiB
#13 Accepted 6ms 7.277 MiB
#14 Accepted 9ms 7.418 MiB
#15 Accepted 6ms 7.277 MiB
#16 Accepted 7ms 7.227 MiB
#17 Accepted 8ms 7.27 MiB
#18 Accepted 6ms 7.43 MiB
#19 Accepted 6ms 7.277 MiB
#20 Accepted 7ms 7.18 MiB
#21 Accepted 8ms 7.328 MiB
#22 Accepted 21ms 7.996 MiB
#23 Accepted 32ms 8.102 MiB
#24 Accepted 33ms 8.125 MiB
#25 Accepted 38ms 8.844 MiB
#26 Accepted 16ms 7.852 MiB
#27 Accepted 10ms 7.488 MiB
#28 Accepted 23ms 8.023 MiB
#29 Accepted 23ms 8.293 MiB
#30 Accepted 26ms 8.77 MiB
#31 Accepted 31ms 8.449 MiB
#32 Accepted 32ms 9.062 MiB
#33 Accepted 24ms 8.383 MiB
#34 Accepted 26ms 8.207 MiB
#35 Accepted 29ms 9.023 MiB

Code

#include<bits/stdc++.h>
using namespace std;
const long long M=3e5+10,MOD=1000000007;
typedef long long ll;
int vis[M];
vector<int>edge[M];
vector<int>vec;
void dfs(int x){
	vis[x]=1;
	vec.push_back(x);
	for(int i:edge[x]){
		if(!vis[i]){
			dfs(i);
		}
	}
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int t=1;
    //cin>>t;
    while(t--){
    	int n,k;
    	cin>>n>>k;
    	int x=n+1,y=0;
    	vector<int>a(n);
    	for(auto &i:a)cin>>i;
    	vector<int>d=a;
    	sort(d.begin(),d.end());
    	for(int i=0;i<n;i++){
    		if(d[i]!=a[i]){
    			x=min(x,i);
    			y=max(y,i);
    		}
    	}
    	if(x>y){
    		cout<<"YES\n";
    		cout<<1<<" "<<1<<"\n";
    		return 0;
    	}
    	if(y-x+1>k){
    		cout<<"NO\n";
    		return 0;
    	}
    	cout<<"YES\n";
    	cout<<x+1<<" "<<y+1<<"\n";
    	
    
    
    
    
    
}

    
    return 0;
 
}

Information

Submit By
Type
Submission
Problem
P1120 Stairway to the Skyline
Contest
Lockout contest round-1 ( Araf al jami vs Kamonasish Roy)
Language
C++17 (G++ 13.2.0)
Submit At
2024-10-30 15:40:22
Judged At
2024-10-30 15:40:22
Judged By
Score
100
Total Time
38ms
Peak Memory
9.062 MiB