C

因为数列单调递增暴力模拟即可 但是这榜歪的好奇怪这题没人写

#include <bits/stdc++.h>
//#define int long long
using namespace std;
int t;
int n,m;
int l,r,tot;
long long ans;
int x[3000005],y[3000005],dx,dy;
void solve(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d %d",&x[i],&y[i]);
	}
	for(int i=1;i<=n;i++){
        l=min(x[i],y[i]);
        r=max(x[i-1],y[i-1]);
		if(l>=r){
			ans+=l-r;
            if(x[i-1]!=y[i-1]){
                ans++;
            }
		}
	}
	cout<<ans;
}
signed main(){
    //ios::sync_with_stdio(false);
    solve();
}