求助,为什么我样例都过不了(样例少1)#1能过其他不行 [伤心]
查看原帖
求助,为什么我样例都过不了(样例少1)#1能过其他不行 [伤心]
1417470
LingShuyao606楼主2024/8/16 20:54
#include<bits/stdc++.h>
using namespace std;
int l,m;
bool tree[10011];
int main()
{
	cin>>l>>m;
	for(int i=1;i<=10011;i++) tree[i]=1;
	for(int i=1;i<=m;i++)
	{
		int u,v;
		scanf("%d %d",&u,&v);
		for(int j=u;j<=v;j++)
			tree[j]=0;
	}
	int ans=0;
	for(int i=1;i<=l;i++)
		if(tree[i]==1) ans++;
	cout<<ans;
	return 0;
}
2024/8/16 20:54
加载中...