Skip to content

Instantly share code, notes, and snippets.

@Arjun2002tiwari
Created January 18, 2022 17:14
Show Gist options
  • Save Arjun2002tiwari/acd1c334ea4a867e3b9817086b3d2870 to your computer and use it in GitHub Desktop.
Save Arjun2002tiwari/acd1c334ea4a867e3b9817086b3d2870 to your computer and use it in GitHub Desktop.
import java.util.Scanner;
public class Prod{
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
int max=0;
int num=1;
for(int i=0;i<n;i++){
int a=sc.nextInt();
int b=sc.nextInt();
if((a-b)>0){
int dif=a-b;
if(dif>max){
max=Math.max(dif,max);
num=1;
}
}
else if((b-a>0)){
int dif=b-a;
if(dif>max){
max=Math.max(dif, max);
num=2;
}
}
}
System.out.print(num+" ");
System.out.print(max);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment