Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <math.h>
- #include <string>
- #include <vector>
- #include <set>
- #include <algorithm>
- #include <bitset>
- typedef long long LL;
- using namespace std;
- int main()
- {
- int p,q,l,r;
- cin>>p>>q>>l>>r;
- vector<pair<int,int>> a;
- vector<pair<int,int>> b;
- int temp1,temp2;
- int cnt=0;
- for(int i=0;i<p;i++)
- {
- cin>>temp1>>temp2;
- a.push_back(make_pair(temp1,temp2));
- }
- for(int i=0;i<q;i++)
- {
- cin>>temp1>>temp2;
- b.push_back(make_pair(temp1,temp2));
- }
- for(int i=l;i<=r;i++)
- {
- for(int j=0;j<b.size();j++)
- {
- for(int k=0;k<a.size();k++)
- {
- if((b[j].first+i>=a[k].first && b[j].first+i<=a[k].second) || (b[j].second+i>=a[k].first && b[j].second+i<=a[k].second))
- cnt++;
- }
- }
- }
- cout<<cnt;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement