woshishabi3 @ 2024-11-09 15:01:55
#include<iostream>
using namespace std;
int main(){
long long l,m,u,v;
cin>>l>>m;
long long sum=l,n=0,y=0;
for(int i=1;i<=m;i++){
cin>>u>>v;
if(v>y&&u>y)sum=sum-(v-u);
else if(v<=y&&u<=n)sum=sum-(n-u);
else if(v<=y&&v>=n)sum=sum-(n-u);
else sum=sum+0;
n=u;
y=v;
}
cout<<sum;
return 0;
}
by woshishabi3 @ 2024-11-09 15:04:47
为什吗样例298,我是299?改前300.不应该是正百数吗?