Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- const int Nmax = 100005;
- int a[Nmax] , n;
- int main()
- {
- cin >> n;
- for(int i = 1 ; i <= n ; i++)
- cin >> a[i];
- sort(a + 1 , a + n + 1 , greater < int > ());
- long long mx = 0 , sum = 0;
- for(int i = 1 ; i <= n ; i++)
- {
- sum += a[i];
- if(i % 2 == 0)
- mx = max(mx , sum);
- }
- cout << mx << "\n";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment