#include<bits/stdc++.h>
using namespace std;
struct node{
int start,end;
}a[5100];
int n;
long long you,wu;
bool cmp(node x,node y)
{
return x.end<y.end;
}
int main()
{
cin>>n;
for(int i=1;i<=n;i++)
{
cin>>a[i].start>>a[i].end;
}
int last = a[1].end;
you += a[1].end - a[1].start;
for(int i=2;i<=n;i++)
{
if(a[i].start == last)
{
you += a[i].end - a[i].start;
}
else if(a[i].start < last)
{
a[i].start = last;
you += a[i].end - a[i].start;
}else
{
wu += a[i].start - last;
}
last = a[i].end;
}
cout<<you<<" "<<wu;
return 0;
}
55555…………
帮帮我吧!!