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