Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class f10HalfSumElement {
- public static void main(String[] args) {
- Scanner scan = new Scanner(System.in);
- int n = Integer.parseInt(scan.nextLine());
- int max = Integer.MIN_VALUE;
- int allSum = 0;
- for(int i=0 ; i<n ; i++){
- int num = Integer.parseInt(scan.nextLine());
- allSum = allSum + num;
- if(num > max){
- max = num;
- }
- }
- if(max == allSum - max){
- System.out.println("Yes Sum = " + max);
- }else{
- System.out.println("No Diff = " + Math.abs(max -(allSum - max)));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement