-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathC.cpp
More file actions
38 lines (35 loc) · 653 Bytes
/
C.cpp
File metadata and controls
38 lines (35 loc) · 653 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
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n,t;
cin>>t;
while(t--)
{
cin>>n;
int ans=0;
vector <int> v(n);
for(int i=0;i<n;i++)
cin>>v[i];
int i=0,j=n-1,k;
while((j-i)>1)
{
k=min(v[i],v[j]);
if(k==v[j] && k<=v[j-1])
{
j--;
}
else if(k==v[i] && k<=v[i+1])
{
i++;
}
else
{
ans=i+1;
i++;
}
}
cout<<ans<<endl;
}
return 0;
}