-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathA.cpp
45 lines (45 loc) · 726 Bytes
/
A.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
#include<stdio.h>
int main()
{
int n,i,j,k,min,max,ans,ara[102];
scanf("%d",&n);
for(i=0;i<n;i++)
scanf("%d",&ara[i]);
for(i=0;i<n;i++)
{
if(i==0)
{
min=ara[i];
j=i;
}
else if(ara[i]<=min)
{
min=ara[i];
j=i;
}
}
for(i=0;i<n;i++)
{
if(i==0)
{
max=ara[i];
k=i;
}
else if(ara[i]>max)
{
max=ara[i];
k=i;
}
}
if(min==max)
printf("0");
else
{
if(k<j)
ans=k+(n-1-j);
else
ans=k+(n-1-j)-1;
printf("%d",ans);
}
return 0;
}