Created
January 18, 2022 17:14
-
-
Save Arjun2002tiwari/acd1c334ea4a867e3b9817086b3d2870 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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