Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class HalfSumElement {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int n = Integer.parseInt(scanner.nextLine());
- int sumNumbers = 0, maxNumber = 0;
- for (int i = 1; i <= n; i++) {
- int number = Integer.parseInt(scanner.nextLine());
- sumNumbers += number;
- if (number > maxNumber) {
- maxNumber = number;
- }
- }
- int result = sumNumbers - maxNumber;
- if (maxNumber == result) {
- System.out.printf("Yes\nSum = %d\n", maxNumber);
- } else {
- System.out.printf("No\nDiff = %d\n", Math.abs(maxNumber - result));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement