import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; import java.util.StringTokenizer; public class kie { public static void main(String[] args) throws IOException { BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer tokenizer; tokenizer = new StringTokenizer(reader.readLine()); int n = Integer.parseInt(tokenizer.nextToken()); tokenizer = new StringTokenizer(reader.readLine()); long minOdd = Long.MAX_VALUE; long oddCount = 0L; long sum = 0L; for(int i = 0; i < n; i++) { long a = Integer.parseInt(tokenizer.nextToken()); sum += a; if(a % 2 == 1) { oddCount++; minOdd = Math.min(minOdd, a); } } long ret = sum; if(oddCount % 2 == 1 && minOdd < Long.MAX_VALUE) { ret -= minOdd; } System.out.println((ret == 0 ? "NIESTETY" : ret)); return; } }
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 | import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; import java.util.StringTokenizer; public class kie { public static void main(String[] args) throws IOException { BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer tokenizer; tokenizer = new StringTokenizer(reader.readLine()); int n = Integer.parseInt(tokenizer.nextToken()); tokenizer = new StringTokenizer(reader.readLine()); long minOdd = Long.MAX_VALUE; long oddCount = 0L; long sum = 0L; for(int i = 0; i < n; i++) { long a = Integer.parseInt(tokenizer.nextToken()); sum += a; if(a % 2 == 1) { oddCount++; minOdd = Math.min(minOdd, a); } } long ret = sum; if(oddCount % 2 == 1 && minOdd < Long.MAX_VALUE) { ret -= minOdd; } System.out.println((ret == 0 ? "NIESTETY" : ret)); return; } } |