Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- int main()
- {
- vector<int>vt;
- int n,x,total=0,ln,i;
- cin>>n;
- while(n--){
- cin>>x;
- vt.push_back(x);
- }
- sort(vt.begin(),vt.end());
- ln=vt.size();
- for(i=1;i<ln;i+=2){
- total=total+(vt[i]-vt[i-1]);
- }
- cout<<total<<endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement