-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathB.cpp
More file actions
74 lines (74 loc) · 1022 Bytes
/
B.cpp
File metadata and controls
74 lines (74 loc) · 1022 Bytes
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#include <stdio.h>
#include <stdlib.h>
int main()
{
int n,a[100000],count=0,l,r,mark=0;
scanf("%d",&n);
r=n-1;
for(int i=0;i<n;i++)
{
scanf("%d",a+i);
}
for(int i=0;i<n-1;i++)
{
if(a[i]>a[i+1] && mark==0)
{
count++;
mark=1;
l=i;
}
if(mark==1 && a[i]<a[i+1])
{
mark=0;
r=i;
}
}
if(count==0)
{
printf("yes\n1 1");
}
else if(count>1)
{
printf("no");
}
else
{
if(l==0 && r==n-1)
{
printf("yes\n%d %d",1,n);
}
else if(l==0)
{
if(a[l]<a[r+1])
{
printf("yes\n%d %d",l+1,r+1);
}
else
{
printf("no");
}
}
else if(r==n-1)
{
if(a[r]>a[l-1])
{
printf("yes\n%d %d",l+1,r+1);
}
else
{
printf("no");
}
}
else{
if(a[l]<a[r+1] && a[r]>a[l-1])
{
printf("yes\n%d %d",l+1,r+1);
}
else
{
printf("no");
}
}
}
return 0;
}