小白求教,就过了三个测试点
查看原帖
小白求教,就过了三个测试点
816647
asdf_楼主2022/12/17 21:22
int tot; 
int b; 
int i;
int ans=0;
int q,p;
int a[10005];
cin>>tot>>b;
for(i=0;i<tot;i++){
	a[i]=i;
}
                    
while(b--){
	cin>>q>>p;
	for(i=q;i<=p;i++){
		a[i]=-1;
	}
}

for(i=0;i<=tot;i++){
	if(a[i]>=0){
		ans++;
	}
}
cout<<ans;
return 0;

}

2022/12/17 21:22
加载中...