0
已解决
曹博扬
初级天翼
初级天翼
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
using namespace std;
int n;
long long s;
int st=-0x3f3f3f3f;
struct f{
int x,y;
}a[105];
bool cmp(f a,f b){
if(a.x!=b.x)
return a.x<b.x;
return a.y<b.y;
}
int main(){
cin>>n;
for(int i=1;i<=n;i++)
cin>>a[i].x>>a[i].y;
sort(a+1,a+n+1,cmp);
st=max(a[1].y,st);
for(int i=2;i<=n;i++){
if(a[i].x>=st){
s+=(a[i].x-st);
st=a[i].y;
}
}
cout<<s;
return 0;
}
快!!