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