/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 7ms 7.191 MiB
#2 Accepted 7ms 7.297 MiB
#3 Accepted 7ms 7.312 MiB
#4 Accepted 7ms 7.387 MiB
#5 Accepted 7ms 7.199 MiB
#6 Accepted 7ms 7.352 MiB
#7 Accepted 8ms 7.41 MiB
#8 Accepted 7ms 7.234 MiB
#9 Accepted 7ms 7.242 MiB
#10 Accepted 8ms 7.352 MiB
#11 Accepted 7ms 7.312 MiB
#12 Accepted 7ms 7.316 MiB
#13 Accepted 7ms 7.336 MiB
#14 Accepted 7ms 7.25 MiB
#15 Accepted 7ms 7.352 MiB
#16 Accepted 7ms 7.355 MiB
#17 Accepted 7ms 7.43 MiB
#18 Accepted 7ms 7.316 MiB
#19 Accepted 7ms 7.23 MiB
#20 Accepted 7ms 7.27 MiB
#21 Accepted 8ms 7.402 MiB
#22 Accepted 22ms 8.0 MiB
#23 Accepted 22ms 8.039 MiB
#24 Accepted 23ms 8.312 MiB
#25 Accepted 40ms 8.59 MiB
#26 Accepted 18ms 8.012 MiB
#27 Accepted 9ms 7.488 MiB
#28 Accepted 25ms 8.043 MiB
#29 Accepted 26ms 8.066 MiB
#30 Accepted 29ms 8.605 MiB
#31 Accepted 33ms 8.445 MiB
#32 Accepted 31ms 8.641 MiB
#33 Accepted 26ms 8.508 MiB
#34 Accepted 29ms 8.312 MiB
#35 Accepted 29ms 8.945 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-12-17 11:26:10
Judged By
Score
100
Total Time
40ms
Peak Memory
8.945 MiB