Advertisement
jeff69

Untitled

Jan 31st, 2016
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1.  
  2. #include <iomanip>
  3. #include <iostream>
  4. #include <functional>
  5. #include <algorithm>
  6. using namespace std;
  7.  
  8. int main()
  9. {
  10. int n;
  11. cin >> n;
  12. long long int a[100000];
  13. long long sum = 0;
  14. for (int s = 0; s<n; s++)
  15. {
  16. cin >> a[s];
  17. sum += a[s];
  18. }
  19. int temp;
  20. for (int i = 0; i < n; i++)
  21. {
  22. for (int j = 0; j<n - 1; j++)
  23. if (a[j]>a[j + 1])
  24. {
  25. temp = a[j];
  26. a[j] = a[j + 1];
  27. a[j + 1] = temp;
  28. }
  29. }
  30.  
  31. int r = 0;
  32. int q = -1;
  33. if (sum % 2 == 1)
  34. {
  35. while (r == 0 && q<n + 1)
  36. {
  37.  
  38. q++;
  39. r = a[q] % 2;
  40. }
  41. sum = sum - a[q];
  42. }
  43.  
  44. cout << sum;
  45.  
  46. return 0;
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement