Advertisement
jeff69

المسالة الاولى

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