Advertisement
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 num = Integer.parseInt(scanner.nextLine());
- int equalValue = Integer.parseInt(scanner.nextLine()) + Integer.parseInt(scanner.nextLine());
- int maxiff = 0;
- int maxDiff = 0;
- for (int i = 1; i < num; i++) {
- int currentValue = Integer.parseInt(scanner.nextLine()) + Integer.parseInt(scanner.nextLine());
- int currentDiff = Math.abs(equalValue - currentValue);
- if (currentDiff > maxDiff) {
- maxDiff = currentDiff;
- } else {
- equalValue = currentValue;
- }
- }
- if (maxDiff == 0) {
- System.out.printf("Yes, value=%d", equalValue);
- } else {
- System.out.printf("No, maxdiff=%d", maxDiff);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement