import java.io.IOException;
import java.util.Scanner;
public class kie {
public static void main(String args[]) throws IOException {
Scanner scanner = new Scanner(System.in);
int n = scanner.nextInt();
// read and process bank notes
long sum = 0;
int number_of_odd = 0;
int min_odd = Integer.MAX_VALUE;
for (int i = 0; i < n; i++) {
int current = scanner.nextInt();
sum += current;
if(current % 2 == 1){
number_of_odd++;
if(current < min_odd){
min_odd = current;
}
}
}
if(n == 1 && number_of_odd == 1){
System.out.println("NIESTETY");
}
else if(number_of_odd % 2 == 0){
System.out.println(sum);
}
else{
System.out.println(sum - min_odd);
}
scanner.close();
}
}
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 | import java.io.IOException; import java.util.Scanner; public class kie { public static void main(String args[]) throws IOException { Scanner scanner = new Scanner(System.in); int n = scanner.nextInt(); // read and process bank notes long sum = 0; int number_of_odd = 0; int min_odd = Integer.MAX_VALUE; for (int i = 0; i < n; i++) { int current = scanner.nextInt(); sum += current; if(current % 2 == 1){ number_of_odd++; if(current < min_odd){ min_odd = current; } } } if(n == 1 && number_of_odd == 1){ System.out.println("NIESTETY"); } else if(number_of_odd % 2 == 0){ System.out.println(sum); } else{ System.out.println(sum - min_odd); } scanner.close(); } } |
English