Dimitar46

EdnakviDvoiki

Jun 29th, 2021 (edited)
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.92 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class P08EqualPairs {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.         int n = Integer.parseInt(scanner.nextLine());
  7.         int currentSum = 0;
  8.         int minSum = Integer.MAX_VALUE;
  9.         int maxSum = Integer.MIN_VALUE;
  10.         for(int i = 1;i<=n;i++){
  11.             int number1 = Integer.parseInt(scanner.nextLine());
  12.             int number2 = Integer.parseInt(scanner.nextLine());
  13.             currentSum =  number1 + number2;
  14.             if(currentSum <minSum){
  15.                 minSum = currentSum;
  16.             }
  17.             if(currentSum > maxSum) {
  18.                 maxSum = currentSum;
  19.             }
  20.  
  21.         }
  22.         if(minSum == maxSum ){
  23.             System.out.printf("Yes, value=%d",minSum);
  24.         }
  25.         else {
  26.             System.out.printf("No, maxdiff=%d",maxSum - minSum);
  27.                 }
  28.         }
  29.     }
  30.  
Add Comment
Please, Sign In to add comment