import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.PrintStream; import java.util.Scanner; public class kie { private int nextInt(InputStream is) { int retValue = 0; try { while (true) { int t = is.read(); if (t==' ' || t=='\r' || t=='\n' || t==-1){ if (retValue==0) continue; break; } retValue=10*retValue + (t-'0'); } } catch (IOException e) { e.printStackTrace(); } return retValue; } public void a(InputStream is, PrintStream ps) throws Exception { long t1=System.currentTimeMillis(); //Scanner scanner = new Scanner(System.in); //int n = scanner.nextInt(); int n = nextInt(is); int a = 0; long r = 0; int minOddAdded = 1001; for (int i=0;i<n;i++){ //a = scanner.nextInt(); a = nextInt(is); if (a%2==1 && minOddAdded>a) minOddAdded=a; r += a; } if (r%2==1 && minOddAdded != 1001) r-=minOddAdded; if (r==0) ps.println("NIESTETY"); else ps.println(r); //scanner.close(); long t2=System.currentTimeMillis(); //ps.println((t2-t1)/1000.0); } public static void main(String[] args) { kie main = new kie(); try{ main.a(System.in, System.out); } catch (Exception e){ } } }
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 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.PrintStream; import java.util.Scanner; public class kie { private int nextInt(InputStream is) { int retValue = 0; try { while (true) { int t = is.read(); if (t==' ' || t=='\r' || t=='\n' || t==-1){ if (retValue==0) continue; break; } retValue=10*retValue + (t-'0'); } } catch (IOException e) { e.printStackTrace(); } return retValue; } public void a(InputStream is, PrintStream ps) throws Exception { long t1=System.currentTimeMillis(); //Scanner scanner = new Scanner(System.in); //int n = scanner.nextInt(); int n = nextInt(is); int a = 0; long r = 0; int minOddAdded = 1001; for (int i=0;i<n;i++){ //a = scanner.nextInt(); a = nextInt(is); if (a%2==1 && minOddAdded>a) minOddAdded=a; r += a; } if (r%2==1 && minOddAdded != 1001) r-=minOddAdded; if (r==0) ps.println("NIESTETY"); else ps.println(r); //scanner.close(); long t2=System.currentTimeMillis(); //ps.println((t2-t1)/1000.0); } public static void main(String[] args) { kie main = new kie(); try{ main.a(System.in, System.out); } catch (Exception e){ } } } |