12 条题解

  • 0
    @ 2025-7-22 9:36:22
     
    #include<bits/stdc++.h>
    using namespace std;
    const int N = 1e5 + 10;
    int a[N];
    int main()
    {
    	int n,m,x,y;
    	cin>>n>>m;
    	for(int i = 0; i < m ;i++)
    	{
    		cin >>x>>y;
    		for(int j=x;j<=y;j++)
    		{
    			a[j]=1;
    		}
    	}
    	int ans = 0;
    	for(int i =0;i<=n; i++ )
    	{
    		if(a[i] == 0)
    			ans++;
    	}
    	cout << ans << endl;
    	return 0;
    }

    信息

    ID
    677
    时间
    1000ms
    内存
    256MiB
    难度
    6
    标签
    递交数
    1078
    已通过
    314
    上传者