zrh041023 @ 2023-11-13 14:41:01
#include<stdio.h>
int main()
{
int l = 0;
int m = 0;
int arr[1000] = { 0 };
int u = 0;
int v = 0;
int sum = 0;
int i = 0;
scanf("%d %d", &l, &m);
for (i = 0; i <= l; i++)
{
arr[i] = i;
}
while (m--)
{
scanf("%d %d", &u, &v);
for (i = u; i <= v; i++)
{
arr[i] = -1;
}
}
for (i = 0; i <= l; i++)
{
if (arr[i] >= 0)
sum++;
}
printf("%d", sum);
return 0;
}
by yyh0915 @ 2023-11-13 15:50:16
@zrh041023 你数组开小了
by yyh0915 @ 2023-11-13 15:51:49
要开到10001
by zrh041023 @ 2023-11-13 16:07:16
@yyh0915 解决了,谢谢哥