xuanbrother @ 2023-06-25 21:57:35
#include <stdio.h>
int main()
{
int l,m;
scanf("%d%d", &l, &m);
int tree[l+1]={0};
while(m--)
{
int u,v;
scanf("%d%d", &u, &v);
for(int i=u-1; i<v; i++)
tree[i]=1;
}
int cnt=0;
for(int i=0; i<l+1; i++)
if(!tree[i]) cnt++;
printf("%d", cnt);
return 0;
}
by lzg_070506 @ 2023-06-25 22:00:38
数组长度不能用变量
by xuanbrother @ 2023-06-26 04:23:06
@lzg_070506 懂了懂了,感谢!