-
Notifications
You must be signed in to change notification settings - Fork 0
/
div2q6.cpp
48 lines (42 loc) · 989 Bytes
/
div2q6.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include <iostream>
using namespace std;
#include<cmath>
//typedef long double l;
#include<stdio.h>
#include<algorithm>
#include<cmath>
int main()
{
int n;
cin>>n;
int A[n];
int flags=-1;
int flage=0;
cin>>A[0];
int flagm=-1;
int band=0;
for(int i=1;i<n;i++){
cin>>A[i];
if(A[i]<A[i-1] && flags==-1) flags=i-1;
if(flags!=-1 && A[i]<A[i-1]) flage++;
if(A[i]>A[i-1] && flags!=-1) flagm=i;
if(A[i]<A[i-1] && flagm!=-1) band=1;
}
flage+=flags;
//cout<<"flags:"<<flags<<""<<flage;
if(flags==-1){cout<<"yes"<<endl<<flags+2<<" "<<flags+2;return 0;}
if(band==1){ cout<<"no";return 0;}
/*for(int i=0;i<n;i++){
cout<<A[i]<<" ";
}
cout<<endl;*/
sort(A+flags,A+flage+1);
/*for(int i=0;i<n;i++){
cout<<A[i]<<" ";
}*/
for(int i=1;i<n;i++){
if(A[i]<A[i-1]){cout<<"no";return 0;}
}
cout<<"yes"<<endl<<flags+1<<" "<<flage+1;
return 0;
}