Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class P08EqualPairs {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int n = Integer.parseInt(scanner.nextLine());
- int currentSum = 0;
- int minSum = Integer.MAX_VALUE;
- int maxSum = Integer.MIN_VALUE;
- for(int i = 1;i<=n;i++){
- int number1 = Integer.parseInt(scanner.nextLine());
- int number2 = Integer.parseInt(scanner.nextLine());
- currentSum = number1 + number2;
- if(currentSum <minSum){
- minSum = currentSum;
- }
- if(currentSum > maxSum) {
- maxSum = currentSum;
- }
- }
- if(minSum == maxSum ){
- System.out.printf("Yes, value=%d",minSum);
- }
- else {
- System.out.printf("No, maxdiff=%d",maxSum - minSum);
- }
- }
- }
Add Comment
Please, Sign In to add comment