#include<bits/stdc++.h> usingnamespace std; structnode { int y; int r; int prenum; int p; } s[100002]; boolcmp(node a, node b) { return a.y > b.y; } intmain() { int n, sum0 = 0; cin >> n; for (int i = 0; i < n; i++) { cin >> s[i].y >> s[i].r; if (s[i].r == 0) { sum0++; } } sort(s, s + n, cmp); int pre1 = 0; for (int i = 0; i < n; i++) { s[i].prenum = pre1; int j, t = 0; s[i].p = pre1; for (j = i; j < n && s[j].y == s[i].y; j++) {