-
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathtype of array.cpp
More file actions
36 lines (36 loc) · 711 Bytes
/
type of array.cpp
File metadata and controls
36 lines (36 loc) · 711 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
#include <iostream>
using namespace std;
int main()
{
//code
int t;
cin>>t;
while(t--)
{
long long int n, i, p=0, q=0;
cin>>n;
long long int a[n], dup[n];
for(i=0; i<n; i++)
{
cin>>a[i];
dup[i]=a[i];
}
sort(dup, dup+n);
for(i=0; i<n; i++)
{
if(dup[0]==a[i])
p=i;
else if(dup[n-1]==a[i])
q=i;
}
if(p==0 && q==(n-1))
cout<<dup[n-1]<<" "<<1<<endl;
else if(p==n-1 && q==0)
cout<<dup[n-1]<<" "<<2<<endl;
else if(p<q)
cout<<dup[n-1]<<" "<<3<<endl;
else if(p>q)
cout<<dup[n-1]<<" "<<4<<endl;
}
return 0;
}