import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
public class kie {
private static int readInt(InputStream in) throws IOException {
int ret = 0;
boolean dig = false;
for (int c = 0; (c = in.read()) != -1;) {
if (c >= '0' && c <= '9') {
dig = true;
ret = ret * 10 + c - '0';
} else if (dig) {
break;
}
}
return ret;
}
public static void main(String[] args) throws IOException {
BufferedInputStream bis = new BufferedInputStream(System.in);
long wynik = 0l;
long maxValue = 1000l;
long minOdd = maxValue;
long n = readInt(bis);
for (int i = 1; i <= n; i++) {
long lTmp = readInt(bis);
if ((lTmp & 1) != 0 && minOdd > lTmp) {
minOdd = lTmp;
}
wynik += lTmp;
}
if ((wynik & 1) != 0) {
if (minOdd != maxValue) {
wynik -= minOdd;
}
}
System.out.print((wynik > 0 ? "" + wynik : "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 34 35 36 37 38 39 40 41 42 43 | import java.io.BufferedInputStream; import java.io.IOException; import java.io.InputStream; public class kie { private static int readInt(InputStream in) throws IOException { int ret = 0; boolean dig = false; for (int c = 0; (c = in.read()) != -1;) { if (c >= '0' && c <= '9') { dig = true; ret = ret * 10 + c - '0'; } else if (dig) { break; } } return ret; } public static void main(String[] args) throws IOException { BufferedInputStream bis = new BufferedInputStream(System.in); long wynik = 0l; long maxValue = 1000l; long minOdd = maxValue; long n = readInt(bis); for (int i = 1; i <= n; i++) { long lTmp = readInt(bis); if ((lTmp & 1) != 0 && minOdd > lTmp) { minOdd = lTmp; } wynik += lTmp; } if ((wynik & 1) != 0) { if (minOdd != maxValue) { wynik -= minOdd; } } System.out.print((wynik > 0 ? "" + wynik : "NIESTETY")); } } |
English