import java.io.BufferedReader; import java.io.InputStreamReader; public class kie { public static void main(final String ... args) throws Exception { final BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); String line = in.readLine(); line = in.readLine(); String[] splittedLine = line.split(" "); int[] numbers = new int[splittedLine.length]; int sum = 0; int minOdd = Integer.MAX_VALUE - 1; for(int i = 0; i < splittedLine.length; i++) { numbers[i] = Integer.parseInt(splittedLine[i]); sum += numbers[i]; if (numbers[i] % 2 == 1 && numbers[i] < minOdd) { minOdd = numbers[i]; } } in.close(); if (sum % 2 == 0) { System.out.println(sum); } else if (minOdd % 2 == 1 && splittedLine.length > 1) { System.out.println(sum - minOdd); } else { System.out.println("NIESTETY"); } } }
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 | import java.io.BufferedReader; import java.io.InputStreamReader; public class kie { public static void main(final String ... args) throws Exception { final BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); String line = in.readLine(); line = in.readLine(); String[] splittedLine = line.split(" "); int[] numbers = new int[splittedLine.length]; int sum = 0; int minOdd = Integer.MAX_VALUE - 1; for(int i = 0; i < splittedLine.length; i++) { numbers[i] = Integer.parseInt(splittedLine[i]); sum += numbers[i]; if (numbers[i] % 2 == 1 && numbers[i] < minOdd) { minOdd = numbers[i]; } } in.close(); if (sum % 2 == 0) { System.out.println(sum); } else if (minOdd % 2 == 1 && splittedLine.length > 1) { System.out.println(sum - minOdd); } else { System.out.println("NIESTETY"); } } } |