here is only basic implementation of problems for beginners. If you have any problem with any solution or any basic concept of programming or you want more efficient solution you can mail me.
my suggestion is not to copy and paste codes from here try to understand the logic and think why you were not able to solve it.

Saturday, 24 January 2015

Black Widow Rings

problem statement is here


#include<stdio.h>
int main(){
long int max,t,n,ar[10000],br[10000],i,j,p,m;
scanf("%ld",&t);
while(t--){
max=0;m=0;
scanf("%ld",&n);
for(i=0;i<n;i++){
scanf("%ld %ld",&ar[i],&br[i]);
if(ar[i]>max){
max=ar[i];
p=i;
}
}
br[p]=0;
for(i=0;i<n;i++){
if(m<br[i]){
m=br[i];
}
}
if(max>m){
printf("%ld\n",p+1);
}else{
printf("-1\n");
}
}
return 0;
}

No comments:

Post a Comment