import java.util.*; public class kie { public static void main(String[] argv) { Scanner s = new Scanner(System.in); String number = s.nextLine(); int n = Integer.parseInt(number); int sum = 0; int parzyste = 0; int minNieparzyste = 1001; int actualNumber; for(int i = 0; i < n; ++i) { actualNumber = s.nextShort(); sum+=actualNumber; if (actualNumber % 2 == 0) { ++parzyste; } else if(actualNumber < minNieparzyste) { minNieparzyste = actualNumber; } } if( (n-parzyste)%2 == 1 && minNieparzyste < 1001 ) { sum = sum-minNieparzyste; } if(sum==0) { System.out.print("NIESTETY"); } else { System.out.print(sum); } } }
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 | import java.util.*; public class kie { public static void main(String[] argv) { Scanner s = new Scanner(System.in); String number = s.nextLine(); int n = Integer.parseInt(number); int sum = 0; int parzyste = 0; int minNieparzyste = 1001; int actualNumber; for(int i = 0; i < n; ++i) { actualNumber = s.nextShort(); sum+=actualNumber; if (actualNumber % 2 == 0) { ++parzyste; } else if(actualNumber < minNieparzyste) { minNieparzyste = actualNumber; } } if( (n-parzyste)%2 == 1 && minNieparzyste < 1001 ) { sum = sum-minNieparzyste; } if(sum==0) { System.out.print("NIESTETY"); } else { System.out.print(sum); } } } |