SandWave2023 @ 2023-02-20 20:30:10
样例没过
测试点1倒是过了
#include<bits/stdc++.h>
using namespace std;
int l,m,u,v,ans=0,s[10010];
int main()
{
cin>>l>>m;
for(int i=0;i<=l;i++)
{
s[i]=i;
}
for(int i=1;i<=m;i++)
{
cin>>u>>v;
for(int j=u;j<=v;j++)
{
s[j]=0;
}
}
for(int i=0;i<=l;i++)
{
if(s[i]!=0)
{
ans+=1;
}
}
cout<<ans;
return 0;
}
by Sun_Email @ 2023-02-20 20:52:05
@HuangDER 是
s[i]=1
不是
s[i]=i
by Rieman_sum @ 2023-02-20 20:58:13
楼上正解
by SandWave2023 @ 2023-02-22 20:34:19
@Sun_Email
刚看出来,用的i=0
by Sun_Email @ 2023-02-22 20:42:24
@HuangDER 。。。。。。
by Sun_Email @ 2023-02-22 20:42:57
还有 i=0没问题