GuiyuanCo @ 2023-09-10 10:37:48
#include <iostream>
using namespace std;
int main()
{
int n,m;
cin>>n>>m;
int a[n];
for (int i=0;i<n;i++)
{
a[i]=0;
}
for (int i=0;i<=m;i++)
{
int x,y;
cin>>x>>y;
for (int j=x;j<=y;i++)
{
if (a[j])
{
a[j]=0;
n--;
}
}
}
cout<<n;
}
by wangjiayuan @ 2023-09-10 10:41:08
int j=x;j<=y;i++改成int j=x;j<=y;j++
by masiyudr @ 2023-09-10 10:49:33
#include <iostream>
using namespace std;
int main()
{
int n,m;
cin>>n>>m;
int a[n];
for (int i=0;i<=n;i++)
{
a[i]=1;
}
for (int i=0;i<m;i++)
{
int x,y;
cin>>x>>y;
for (int j=x;j<=y;j++)
{
if (a[j])
{
a[j]=0;
n--;
}
}
}
cout<<n+1;
}
by GuiyuanCo @ 2023-09-10 20:24:52
@wangjiayuan 我靠我脑残了