Advertisement
sherry_ahmos

Untitled

Dec 5th, 2022
724
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.37 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <map>
  4. #include <bits/stdc++.h>
  5.  
  6. using namespace std;
  7.  
  8. #define ll long long
  9. #define cy cout << "YES\n"
  10. #define cn cout << "NO\n"
  11. #define nl "\n"
  12. #define fi first
  13. #define se second
  14. #define MOD 1000000007
  15. #define all(v) v.begin(), v.end()
  16. #define sz(s) s.size()
  17. #define f0r(i, n) for (ll i = 0; i < n; i++)
  18. template <typename T = int>
  19. istream &operator>>(istream &in, vector<T> &v)
  20. {
  21.     for (auto &x : v)
  22.         in >> x;
  23.     return in;
  24. }
  25.  
  26. template <typename T = int>
  27. ostream &operator<<(ostream &out, const vector<T> &v)
  28. {
  29.     for (const T &x : v)
  30.         out << x << " ";
  31.     return out;
  32. }
  33.  
  34. void sherry()
  35. {
  36.     ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
  37. #ifndef ONLINE_JUDGE
  38.     freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout);
  39. #endif
  40. }
  41.  
  42. void solve()
  43. {
  44.     ll n;
  45.     cin >> n;
  46.     ll sum =0,odd=LLONG_MAX;
  47.     for(ll i=0;i<n;i++){
  48.         ll num;
  49.         cin>>num;
  50.         sum+=num;
  51.         if(num%2){
  52.             odd=min(odd,num);
  53.         }
  54.     }
  55.     if(odd<LLONG_MAX){
  56.         if(sum%2){
  57.             cout<<sum-odd<<" "<<sum;
  58.         }else{
  59.             cout << sum<<" "<<sum-odd;
  60.         }
  61.     }else
  62.         cout<<sum<<" 0";
  63. }
  64. int main()
  65. {
  66.     sherry();
  67.     int t = 1;
  68.     //cin >> t;
  69.     while (t--)
  70.         solve();
  71.     return 0;
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement