Advertisement
erfanul007

CF B

Dec 18th, 2018
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.32 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int main()
  4. {
  5. vector<int>vt;
  6. int n,x,total=0,ln,i;
  7. cin>>n;
  8. while(n--){
  9. cin>>x;
  10. vt.push_back(x);
  11. }
  12. sort(vt.begin(),vt.end());
  13. ln=vt.size();
  14. for(i=1;i<ln;i+=2){
  15. total=total+(vt[i]-vt[i-1]);
  16. }
  17. cout<<total<<endl;
  18. return 0;
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement