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 scan = new Scanner(System.in);
- int n = scan.nextInt();
- int PreviousSum = 0;
- int CurrentSum = 0;
- int diff = 0;
- for (int i = 1; i <= n; i++) {
- if (i == 1) {
- int num1 = scan.nextInt();
- int num2 = scan.nextInt();
- PreviousSum = num1 + num2;
- } else {
- int num1 = scan.nextInt();
- int num2 = scan.nextInt();
- CurrentSum = num1 + num2;
- if (Math.abs(CurrentSum - PreviousSum) > diff) {
- diff = Math.abs(CurrentSum - PreviousSum);
- }
- PreviousSum = CurrentSum;
- }
- }
- if (diff != 0) {
- System.out.println("No, maxdiff=" + diff);
- } else {
- System.out.println("Yes, value=" + PreviousSum);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment