Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.company;
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- Scanner scan = new Scanner(System.in);
- int n = Integer.parseInt(scan.nextLine());
- int sum = 0;
- int diff = 0;
- int sum2 = 0;
- for (int i = 1; i <= n; i++) {
- int cn = scan.nextInt();
- int cn2 = scan.nextInt();
- sum = cn + cn2;
- if(sum > sum2){
- diff = sum - sum2;
- }else{
- diff = sum2 - sum;
- }
- sum2 = sum;
- }
- if (diff == 0) {
- System.out.println("Yes, value=" + sum);
- }else{
- System.out.println("No, maxdiff=" + diff);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement