求各门各派各路c++大神犇解答哪里错了

#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 条评论

目前还没有评论...

信息

ID
1165
难度
6
分类
模拟 点击显示
标签
递交数
3238
已通过
939
通过率
29%
被复制
14
上传者