#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int MAXN = 200'001;
set<int> a;
multiset<int> b[MAXN];
int vx[MAXN], vy[MAXN];
int curr = 0;
void del(int x, int y) {
auto it = a.lower_bound(x);
while (it != a.begin()) {
it--;
int val = *it;
auto it2 = b[val].begin();
while (it2 != b[val].end() && (*it2) < y) {
curr--;
it2 = b[val].erase(it2);
}
if (b[val].empty()) {
a.erase(val);
it = a.lower_bound(x);
} else {
break;
}
}
}
void insert(int x, int y) {
curr++;
a.insert(x);
b[x].insert(y);
}
void add(int x, int y) {
auto it = a.upper_bound(x);
if (it == a.end()) {
insert(x, y);
} else {
int val = *it;
if ((*b[*it].rbegin()) <= y) {
insert(x, y);
}
}
}
int main() {
ios::sync_with_stdio(0); cin.tie(0);
int n; cin >> n;
vector<int> comp;
for (int i = 1; i <= n; i++) {
cin >> vx[i] >> vy[i];
comp.emplace_back(vx[i]);
}
sort(comp.begin(), comp.end());
comp.erase(unique(comp.begin(), comp.end()), comp.end());
for (int i = 1; i <= n; i++) vx[i] = lower_bound(comp.begin(), comp.end(), vx[i])-comp.begin();
for (int i = 1; i <= n; i++) {
del(vx[i], vy[i]);
add(vx[i], vy[i]);
cout << curr << "\n";
}
return 0;
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Accepted | 8ms | 20688 KiB | ||||
2 | Accepted | 70ms | 23476 KiB | ||||
subtask2 | 5/5 | ||||||
3 | Accepted | 10ms | 21092 KiB | ||||
4 | Accepted | 9ms | 21044 KiB | ||||
5 | Accepted | 9ms | 21356 KiB | ||||
6 | Accepted | 14ms | 21876 KiB | ||||
subtask3 | 10/10 | ||||||
7 | Accepted | 8ms | 21760 KiB | ||||
8 | Accepted | 10ms | 22060 KiB | ||||
9 | Accepted | 10ms | 21916 KiB | ||||
10 | Accepted | 10ms | 22300 KiB | ||||
11 | Accepted | 10ms | 22492 KiB | ||||
12 | Accepted | 9ms | 22780 KiB | ||||
13 | Accepted | 13ms | 22728 KiB | ||||
14 | Accepted | 13ms | 23036 KiB | ||||
subtask4 | 10/10 | ||||||
15 | Accepted | 10ms | 22880 KiB | ||||
16 | Accepted | 9ms | 23036 KiB | ||||
17 | Accepted | 10ms | 22936 KiB | ||||
18 | Accepted | 12ms | 23084 KiB | ||||
19 | Accepted | 14ms | 23364 KiB | ||||
20 | Accepted | 20ms | 23852 KiB | ||||
21 | Accepted | 19ms | 23808 KiB | ||||
22 | Accepted | 71ms | 34724 KiB | ||||
subtask5 | 25/25 | ||||||
23 | Accepted | 8ms | 23140 KiB | ||||
24 | Accepted | 10ms | 23148 KiB | ||||
25 | Accepted | 12ms | 23448 KiB | ||||
26 | Accepted | 13ms | 23584 KiB | ||||
27 | Accepted | 39ms | 24572 KiB | ||||
28 | Accepted | 54ms | 25440 KiB | ||||
29 | Accepted | 68ms | 25832 KiB | ||||
30 | Accepted | 67ms | 25916 KiB | ||||
subtask6 | 50/50 | ||||||
31 | Accepted | 10ms | 23280 KiB | ||||
32 | Accepted | 70ms | 25824 KiB | ||||
33 | Accepted | 10ms | 21092 KiB | ||||
34 | Accepted | 9ms | 21044 KiB | ||||
35 | Accepted | 9ms | 21356 KiB | ||||
36 | Accepted | 14ms | 21876 KiB | ||||
37 | Accepted | 8ms | 21760 KiB | ||||
38 | Accepted | 10ms | 22060 KiB | ||||
39 | Accepted | 10ms | 21916 KiB | ||||
40 | Accepted | 10ms | 22300 KiB | ||||
41 | Accepted | 10ms | 22492 KiB | ||||
42 | Accepted | 9ms | 22780 KiB | ||||
43 | Accepted | 13ms | 22728 KiB | ||||
44 | Accepted | 13ms | 23036 KiB | ||||
45 | Accepted | 10ms | 22880 KiB | ||||
46 | Accepted | 9ms | 23036 KiB | ||||
47 | Accepted | 10ms | 22936 KiB | ||||
48 | Accepted | 12ms | 23084 KiB | ||||
49 | Accepted | 14ms | 23364 KiB | ||||
50 | Accepted | 20ms | 23852 KiB | ||||
51 | Accepted | 19ms | 23808 KiB | ||||
52 | Accepted | 71ms | 34724 KiB | ||||
53 | Accepted | 8ms | 23140 KiB | ||||
54 | Accepted | 10ms | 23148 KiB | ||||
55 | Accepted | 12ms | 23448 KiB | ||||
56 | Accepted | 13ms | 23584 KiB | ||||
57 | Accepted | 39ms | 24572 KiB | ||||
58 | Accepted | 54ms | 25440 KiB | ||||
59 | Accepted | 68ms | 25832 KiB | ||||
60 | Accepted | 67ms | 25916 KiB | ||||
61 | Accepted | 14ms | 23648 KiB | ||||
62 | Accepted | 14ms | 23508 KiB | ||||
63 | Accepted | 13ms | 23508 KiB | ||||
64 | Accepted | 41ms | 29128 KiB | ||||
65 | Accepted | 14ms | 23508 KiB | ||||
66 | Accepted | 12ms | 23808 KiB | ||||
67 | Accepted | 12ms | 24028 KiB | ||||
68 | Accepted | 13ms | 23928 KiB | ||||
69 | Accepted | 59ms | 26460 KiB | ||||
70 | Accepted | 275ms | 66028 KiB |