rt,没想明白哪错了
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
const int N = 1e5 + 5;
int n;
int x[N];
int main()
{
long long ans = 0;
scanf("%d", &n);
for (int i = 1; i <= n; i ++ )
{
int a, b;
scanf("%d%d", &a, &b);
x[i] = max(b, a - b);
}
sort(x + 1, x + n + 1);
reverse(x + 1, x + n + 1);
ans += x[1] + x[2];
printf("%lld\n", ans);
return 0;
}