Saleh127

codeforces 1144B.cpp

May 30th, 2020
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define test int t; cin>>t; while (t--)
  4. #define ll long long int
  5. #define pi acos(-1)
  6. int main()
  7. {
  8. ll e[10000],o[10000],a,c,d,f,i,j=0,k=0,ans=0;
  9. cin>>c;
  10. while(c--)
  11. {
  12. cin>>d;
  13. if(d%2) o[j++]=d;
  14. else e[k++]=d;
  15. }
  16. if(j>k)
  17. {
  18. sort(o,o+j);
  19. for(i=0;i<j-k-1;i++)
  20. {
  21. ans+=o[i];
  22. }
  23. }
  24. else
  25. {
  26. sort(e,e+k);
  27. for(i=0;i<k-j-1;i++)
  28. {
  29. ans+=e[i];
  30. }
  31. }
  32. cout<<ans<<endl;
  33. return 0;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment