Advertisement
Mishakis

LeftRightSide

Aug 2nd, 2017
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.85 KB | None | 0 0
  1. package com.company;
  2.  
  3. import com.sun.org.apache.xpath.internal.SourceTree;
  4.  
  5. import java.time.chrono.MinguoEra;
  6. import java.util.Scanner;
  7.  
  8. public class Main {
  9.  
  10.     public static void main(String[] args) {
  11.         Scanner scanner = new Scanner(System.in);
  12.  
  13.         int n = Integer.parseInt(scanner.nextLine());
  14.         int sumL=0;
  15.         int sumR=0;
  16.  
  17.         for (int i = 0; i < n ; i++) {
  18.             int left = Integer.parseInt(scanner.nextLine());
  19.             sumL += left;
  20.         }
  21.        
  22.         for (int i = 0; i < n; i++) {
  23.             int right = Integer.parseInt(scanner.nextLine());
  24.             sumR += right;
  25.         }
  26.  
  27.         int diff = Math.abs(sumL-sumR);
  28.  
  29.         if(diff!=0){
  30.             System.out.println("No, diff " + diff);
  31.         }else{
  32.             System.out.println("Yes, sum " + sumL);
  33.         }
  34.  
  35.     }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement