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