#include <bits/stdc++.h>
using namespace std;
int main()
{
int n;
scanf("%d",&n);
int PS[n]={0};
int CY[n]={0};
int diff[n][2]={0};
for(int i=0;i<n;i++)
{
diff[i][0]=i;
}
for(int i=0;i<n;i++)
{
scanf("%d",&PS[i]);
scanf("%d",&CY[i]);
diff[i][1]=PS[i]-CY[i];
}
for(int mask=1;mask<n;mask++)
{
for(int i=0;i<n-1;i++)
{
if(diff[i][1]>diff[i+1][1])
{
int temp=diff[i][1];
diff[i][1]=diff[i+1][1];
diff[i+1][1]=temp;
temp=diff[i][0];
diff[i][0]=diff[i+1][0];
diff[i+1][0]=temp;
}
}
}
long long res=0;
for(int i=0;i<n/2;i++)
{
res+=CY[diff[i][0]];
}
for(int i=n/2;i<n;i++)
{
res+=PS[diff[i][0]];
}
cout<<res<<endl;
}
Copy