import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; public class kie { public static void main(String[] args) { try { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String first = br.readLine(); String second = br.readLine(); String[] numbers = second.split(" "); Integer[] nums = map(numbers); solve(nums); } catch (IOException io) { io.printStackTrace(); } } private static void solve(Integer[] nums) { long sum = 0; for (int i = 0; i < nums.length; i++) { sum += nums[i]; } if(sum%2==0) System.out.println(sum); Arrays.sort(nums); for(int i=0;i<nums.length;i++){ if(nums[i]%2!=0) { sum-=nums[i]; if(sum!=0) System.out.println(sum); else System.out.println("NIESTETY"); return; } } } private static Integer[] map(String[] numbers) { Integer[] nums = new Integer[numbers.length]; for (int i = 0; i < numbers.length; i++) { nums[i] = Integer.parseInt(numbers[i]); } return nums; } }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; public class kie { public static void main(String[] args) { try { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String first = br.readLine(); String second = br.readLine(); String[] numbers = second.split(" "); Integer[] nums = map(numbers); solve(nums); } catch (IOException io) { io.printStackTrace(); } } private static void solve(Integer[] nums) { long sum = 0; for (int i = 0; i < nums.length; i++) { sum += nums[i]; } if(sum%2==0) System.out.println(sum); Arrays.sort(nums); for(int i=0;i<nums.length;i++){ if(nums[i]%2!=0) { sum-=nums[i]; if(sum!=0) System.out.println(sum); else System.out.println("NIESTETY"); return; } } } private static Integer[] map(String[] numbers) { Integer[] nums = new Integer[numbers.length]; for (int i = 0; i < numbers.length; i++) { nums[i] = Integer.parseInt(numbers[i]); } return nums; } } |