还有数据中并没有出现超 int 的数据,即可卡掉下面的代码:
```cpp
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
int n;
cin >> n;
vector<pair<int,int>> a(n);
for (int i=0;i<n;++i){
scanf("%d%d",&a[i].first,&a[i].second);
}
sort(a.begin(),a.end());
pair<int,int> t=a[0];
int ans=0;
for (int i=1;i<n;++i){
if (a[i].first<=t.second){//合并
t.second=max(t.second,a[i].second);
}else{//中断
ans+=t.second-t.first+1;
t=a[i];//新区间
}
}
cout<<ans+t.second-t.first+1<<endl;//最后还剩一个区间
return 0;
}
```
in:
```
1
10000000000 100000000001
```
ans:
```
90000000002
```
代码out:
```
1
```
by xiaoyang222 @ 2024-02-05 10:54:47
题解区没看有没有被hack的
by xiaoyang222 @ 2024-02-05 10:56:39
@[Acoipp](/user/674469)
@[honglan0301](/user/529697)
@[Wuyanru](/user/400201)
by gotocspandbetter @ 2024-02-05 11:00:08
@[gotocspandbetter](/user/1041003) @[xiaoyang222](/user/1220111)
没有 hack 题解请不要 at 题解审核志愿者谢谢喵~
by Acoipp @ 2024-02-05 11:02:26
@[yummy](/user/101694) 的输出4
@[人间凡人](/user/238925) 的输出2
@[Dr_殇](/user/28182) 的莫名其妙TLE了
有三篇题解被hack掉了
by Razer_System @ 2024-02-05 11:13:05
@[Razer_System](/user/766788) 等我当上题解管理了就紫砂(???
by yummy @ 2024-02-05 11:49:36
@[yummy](/user/101694) 这么牛
by Wuyanru @ 2024-02-05 11:51:45
@[xiaoyang222](/user/1220111) 谢谢,我已经自己改掉并自己通过了(((
by yummy @ 2024-02-05 13:48:54
所以说之前的范围是不是 $10^{17}$?
by xiaoyang222 @ 2024-02-05 13:52:43