题意
Sol
我是这样考虑的:从大到小考虑每个(l, r),最大的(l)应该和最大的(r)匹配(不然就亏了),其次次大的(r)应该和次大的(l)匹配
然后就过了。。
/*
*/
#include<bits/stdc++.h>
#define Pair pair<int, int>
#define MP(x, y) make_pair(x, y)
#define fi first
#define se second
#define int long long
#define LL long long
#define rg register
#define pt(x) printf("%d ", x);
#define Fin(x) {freopen(#x".in","r",stdin);}
#define Fout(x) {freopen(#x".out","w",stdout);}
#define chmin(x, y) (x = x < y ? x : y)
using namespace std;
const int MAXN = 2001, INF = 1e18 + 10, mod = 1e9 + 7;
const double eps = 1e-9;
inline int read() {
char c = getchar(); int x = 0, f = 1;
while(c < '0' || c > '9') {if(c == '-') f = -1; c = getchar();}
while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
return x * f;
}
int N, l[MAXN], r[MAXN], ans;
priority_queue<int> p, q;
main() {
N = read();
for(int i = 1; i <= N; i++) p.push(read()), q.push(read());
for(int i = 1; i <= N; i++) {
int x = p.top(), y = q.top(); p.pop(); q.pop();
ans += max(x, y);
}
cout << ans + N;
return 0;
}