- 火烧赤壁
- 2018-03-08 20:02:25 @
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <cstring>
using namespace std;
int n,ans;
struct burning_of_the_red_cliffs{
int l,r;
}bur[20020];
bool bl(burning_of_the_red_cliffs a,burning_of_the_red_cliffs b){
return a.l<b.r;
}
int main(){
scanf("%d",&n);
for(int i=1;i<=n;i++){
scanf("%d%d",&bur[i].l,&bur[i].r);
}
sort(bur+1,bur+n+1,bl);
int res=0;
for(int i=1;i<=n;i++){
if(bur[i].l<=bur[i-1].r){
ans+=bur[i].r-bur[i-1].r;
}
else{
ans+=bur[i].r-bur[i].l+1;
}
}
printf("%d",ans);
return 0;
}
0 条评论
目前还没有评论...