0
钱卓梁
初级守护
初级守护
题目链接: 酷町堂:2878
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
using namespace std;
int n;
long long s;
int st;
struct f{
int x,y;
}a[10100];
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;
}
急急急!!!