Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<vector>
- #include<map>
- #include<iostream>
- #include<string>
- #include<algorithm>
- using namespace std;
- struct point {
- int x;
- int type;
- point(int x, int type) : x(x), type(type) {}
- point() {}
- bool operator< (const point& Point) const {
- if(x < Point.x) {
- return type > Point.type;
- } else {
- return x < Point.x;
- }
- }
- };
- int main() {
- int n, m,tmp;
- cin >> n >> m;
- vector<point>a(n * 2 + m);
- map<int,int>ans;
- vector<int>key(m);
- for (int i = 0; i < n * 2; i+=2) {
- cin >> a[i].x >> a[i+1].x;
- if (a[i].x < a[i+1].x) {
- a[i].type = 1;
- a[i+1].type = -1;
- } else {
- a[i].type = -1;
- a[i+1].type = 1;
- }
- tmp = i + 2;
- }
- for (int i = 0; tmp < n * 2 + m; tmp++) {
- cin >> a[tmp].x;
- ans[a[tmp].x] = 0;
- key[i] = a[tmp].x;
- a[tmp].type = 0;
- i++;
- }
- sort(a.begin(),a.end());
- for (int i = 0; i < n * 2 + m; i++)
- cout << a[i].x << " ";
- cout << endl;
- for (int i = 0; i < n * 2 + m; i++)
- cout << a[i].type << " ";
- cout << endl;
- int bal = 0;
- for (int i = 0; i < n * 2 + m; i++) {
- if (a[i].type == 0) {
- ans[a[i].x] = bal;
- cout << a[i].x << " " << bal << endl;
- }
- bal+=a[i].type;
- }
- for (int i = 0; i < m; i++)
- cout << ans[key[i]] << " ";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement