-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBWIDOW.c
More file actions
51 lines (51 loc) · 1.02 KB
/
BWIDOW.c
File metadata and controls
51 lines (51 loc) · 1.02 KB
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
#include<stdio.h>
#define gc getchar
inline long long int scan() {
char c = gc();
while(c<'0' || c>'9') c = gc();
long long int ret = 0;
while(c>='0' && c<='9') {
ret = 10 * ret + c - 48;
c = gc();
}
return ret;
}
int main()
{
long long int t,n,i,maxi,maxo[2],maxin;
t=scan();
while(t--)
{
n=scan();
long long int in[n],out[n];
for(i=0;i<n;i++)
{
in[i]=scan();
out[i]=scan();
if(i==0)
{
maxi=0;
maxin=in[i];
maxo[0]=out[i];
}
else
{
if(in[i]>maxin)
{
maxin=in[i];
maxi=i;
}
if(out[i]>maxo[0])
{
maxo[1]=maxo[0];
maxo[0]=out[i];
}
}
}
if(maxin>=maxo[1])
printf("%lld\n",maxi+1);
else
printf("-1\n");
}
return 0;
}