woodQ @ 2023-08-08 17:59:42
为什么前三个通不过??
#include<iostream>
using namespace std;
int main()
{
int arr[100000] = {};
int l, m,u, v,a=0;
cin >> l >> m;
for (int i = 0; i < m; i++)
{
cin >> u >> v;
for (int j = u; j <= v; j++)
{
arr[j] = 1;
}
}
for (int x = 0; x < l; x++)
{
a += arr[x];
}
cout << l-a+1;
}
by ybc2025chenyuyang @ 2023-08-08 18:01:17
@woodQ 同样的错误
by woodQ @ 2023-08-08 18:19:26
@ybc2025125chenyuyang 能不能教一下怎么改?qwq
by ybc2025chenyuyang @ 2023-08-08 18:21:18
@woodQ 最后一个循环条件改成x<=l
by woodQ @ 2023-08-08 18:24:19
@ybc2025125chenyuyang l不是我输入的区域大小吗,数组从0开始循环到l的话区域不就变多了一个吗?
by ybc2025chenyuyang @ 2023-08-08 18:26:29
@woodQ 如果你这么做只有l个呀
by ybc2025chenyuyang @ 2023-08-08 18:27:09
@woodQ 就是要多一个呀,看看题
by woodQ @ 2023-08-08 18:28:55
@ybc2025125chenyuyang 明白了,我眼瞎了QWQ