Saturday, 18 July 2015

BWIDOW

Standard

Black Widow Rings

Link to the question : BWIDOW 

HINT :

The question statement is very much clear, and even you need to solve it using the basic approach. Just compare the ring with the maximum inner radius with the outer radius of other rings. 

RECOMMENDED QUESTION :

Try this question on gcd after this one.

SOURCE CODE :

#include<stdio.h>
int main()
{
    int t;
    scanf("%d",&t);

    while(t--)
    {
        int n;
        scanf("%d",&n);
        long long int a[n][2],max=0,max2=0;
        int i,r,rr;
        for(i=0;i<n;i++)
        {
            scanf("%lld%lld",&a[i][0],&a[i][1]);
            if(a[i][0] > max)
            {
                max = a[i][0];
                r= i;
            }
            else if(a[i][1]>max2)
            {
                max2= a[i][1];

            }
        }

        if(max>max2)
            printf("%d\n",r+1);

        else
            printf("-1\n");
    }
    return 0;
}
 

0 comments:

Post a Comment