Advertisement
Mishakis

HalfSumElement(OneElEqualsTheOthers)

Aug 2nd, 2017
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.79 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 sum = 0;
  15.         int max = Integer.MIN_VALUE;
  16.  
  17.  
  18.         for (int i = 0; i <n ; i++) {
  19.             int num = Integer.parseInt(scanner.nextLine());
  20.             sum += num;
  21.             if(num>max){
  22.                 max=num;
  23.             }else{
  24.  
  25.             }
  26.  
  27.  
  28.         }
  29.         if(max == (sum-max)){
  30.             System.out.println("Yes sum " + max);
  31.         }else{
  32.             System.out.println("No diff " + Math.abs(max-(sum-max)));
  33.         }
  34.  
  35.     }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement