import java.io.*; import java.util.Arrays; import java.util.HashMap; import java.util.Hashtable; import java.util.Scanner; public class kie { public static void main(String[] args) throws IOException { Scanner in = new Scanner(new InputStreamReader(System.in)); int notes = in.nextInt(); long sum = 0; int nieparzysta = Integer.MAX_VALUE; for (int i=0; i<notes; i++) { int banknot = in.nextInt(); sum+=banknot; if (banknot%2==1 && banknot < nieparzysta) { nieparzysta = banknot; } } if (sum%2==1) { sum -= nieparzysta; if (sum==0) System.out.println("NIESTETY"); else System.out.println(sum); } else { System.out.println(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 | import java.io.*; import java.util.Arrays; import java.util.HashMap; import java.util.Hashtable; import java.util.Scanner; public class kie { public static void main(String[] args) throws IOException { Scanner in = new Scanner(new InputStreamReader(System.in)); int notes = in.nextInt(); long sum = 0; int nieparzysta = Integer.MAX_VALUE; for (int i=0; i<notes; i++) { int banknot = in.nextInt(); sum+=banknot; if (banknot%2==1 && banknot < nieparzysta) { nieparzysta = banknot; } } if (sum%2==1) { sum -= nieparzysta; if (sum==0) System.out.println("NIESTETY"); else System.out.println(sum); } else { System.out.println(sum); } } } |