#include <bits/stdc++.h>
using namespace std;
int n;
int time(pair<int,int>a,pair<int,int>b){
if(a.second<=b.first || b.second<=a.first)
return 0;
else if(a.first <= b.first && a.second >= b.second)
return b.second - b.first;
else if(a.first >= b.first && a.second <= b.second)
return a.second - a.first;
else if(a.first >= b.first && a.second >= b.second)
return b.second - a.first;
else if(a.first <= b.first && a.second <= b.second)
return a.second - b.first;
}
int main() {
ios::sync_with_stdio(false);
cin>>n;
pair<int,int>a[n],b[n];
for (int i = 0; i < n; ++i) {
cin>>a[i].first>>a[i].second;
}
long long sum = 0;
for (int i = 0; i < n; ++i) {
cin>>b[i].first>>b[i].second;
for (int j = 0; j < n; ++j) {
sum += time(a[j],b[i]);
}
}
cout<<sum;
return 0;
}
09-14
04-25
06-15
06-15
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交