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