首页 > 代码库 > CodeForces 451B

CodeForces 451B

#include <iostream>

#include <algorithm>

using namespace std;

#define max 100010

int a[max],b[max];

bool cmp(int a,int b){

  return a<b;

}

int main(){

int n;

while(cin>>n){

  for(int i=0;i<n;i++){

    cin>>a[i]; b[i]=a[i];

  }

  sort(a,a+n,cmp);

  int st=0,en=0;

  bool ok1=true,ok2=true;

  for(int i=0;i<n;i++){

    if(a[i]!=b[i]&&ok1){

      st=i;ok1=false;

    }

    if(a[n-1-i]!=b[n-1-i]&&ok2){

      en=n-1-i;

      ok2=false;

    }

    if(!ok1&&!ok2)break;

  }

//cout<<st<<en<<endl;

  bool ok3=true;

  for(int i=st;i<en;i++){

    if(b[i]<b[i+1]){ok3=false;break;}

  }

  if(ok3)cout<<"yes\n"<<st+1<<" "<<en+1<<endl;

  else cout<<"no"<<endl;

}

return 0;

}