CCF201809-02 卖菜

待编辑

代码如下:

#include<bits/stdc++.h>
using namespace std;
int t[1000001];
int main(){
	int n,a,b,c,d;
	int max=0;
	int count=0;
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a>>b;
		if(max<b)
		max=b;
		for(int j=a;j<b;j++){
			t[j]++;
		}
	}
	for(int i=1;i<=n;i++){
		cin>>c>>d;
		if(max<d)
		max=d;		
		for(int j=c;j<d;j++){
			t[j]++;		
		}
	}
	
	for(int i=1;i<max;i++){
		if(t[i]==2)
		count++;
	}
	cout<<count;
	return 0;
}

猜你喜欢

转载自blog.csdn.net/qq_19656301/article/details/82811551