Little_Fox_Fairy @ 2023-04-02 10:29:46
代码:
#include<bits/stdc++.h>
using namespace std;
int a[10086];
int main()
{
int l,m,x,y,s=0;
cin>>l>>m;
for (int i=1;i<=m;i++)
{
cin>>x>>y;
for (int i=1;i<=l;i++)
if ((i>=x)&&(i<=y))
a[i]++;
}
for (int i=0;i<=l;i++)
if (a[i]==0)
s++;
cout<<s;
return 0;
}
一个WA
by kn_wlq @ 2023-04-02 10:35:48
把
for (int i=1;i<=l;i++)
if ((i>=x)&&(i<=y))
a[i]++;
}
改成
for(i=0;i<=l;i++){
if(a[i]==0){
sum++;
}
}
试试
by kn_wlq @ 2023-04-02 10:36:39
我后面那个改的中有sum++,你把sum改成你设的s就行,自测ok
by kn_wlq @ 2023-04-02 10:37:06
求关注
by Little_Fox_Fairy @ 2023-04-02 11:07:20
@kn_wlq 感谢大佬
by Little_Fox_Fairy @ 2023-04-02 11:07:38
@kn_wlq 这就关注