#include <bits/stdc++.h>
using namespace std;
int n;
multiset<pair<int,int>> s;
void ins(int a, int b){
auto it = s.lower_bound(make_pair(a+1,-1));
if(it != s.end()){
it = s.lower_bound(make_pair(it->first+1,-1));
if(it != s.begin()) --it;
if(it->first > a && it->second > b) return;
}
s.insert(make_pair(a,b));
int k = a;
while(1){
it = s.lower_bound(make_pair(k,-1));
if(it == s.begin()) break;
--it;
k = it->first;
it = s.lower_bound(make_pair(k,-1));
while(it != s.end() && it->first < a && it->second < b) it = s.erase(it);
}
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
cin>>n;
for(int i=1;i<=n;i++){
int a,b;
cin>>a>>b;
ins(a,b);
cout << s.size() << '\n';
}
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Accepted | 3ms | 2016 KiB | ||||
2 | Accepted | 35ms | 2324 KiB | ||||
subtask2 | 5/5 | ||||||
3 | Accepted | 3ms | 2448 KiB | ||||
4 | Accepted | 3ms | 2784 KiB | ||||
5 | Accepted | 3ms | 2936 KiB | ||||
6 | Accepted | 4ms | 2964 KiB | ||||
subtask3 | 10/10 | ||||||
7 | Accepted | 3ms | 2952 KiB | ||||
8 | Accepted | 3ms | 3196 KiB | ||||
9 | Accepted | 4ms | 3292 KiB | ||||
10 | Accepted | 3ms | 3364 KiB | ||||
11 | Accepted | 3ms | 3436 KiB | ||||
12 | Accepted | 3ms | 3464 KiB | ||||
13 | Accepted | 4ms | 3696 KiB | ||||
14 | Accepted | 4ms | 3908 KiB | ||||
subtask4 | 10/10 | ||||||
15 | Accepted | 3ms | 3864 KiB | ||||
16 | Accepted | 3ms | 3840 KiB | ||||
17 | Accepted | 3ms | 3848 KiB | ||||
18 | Accepted | 3ms | 3852 KiB | ||||
19 | Accepted | 4ms | 4060 KiB | ||||
20 | Accepted | 8ms | 3944 KiB | ||||
21 | Accepted | 8ms | 4136 KiB | ||||
22 | Accepted | 72ms | 13456 KiB | ||||
subtask5 | 25/25 | ||||||
23 | Accepted | 3ms | 4152 KiB | ||||
24 | Accepted | 3ms | 4168 KiB | ||||
25 | Accepted | 3ms | 4076 KiB | ||||
26 | Accepted | 4ms | 4072 KiB | ||||
27 | Accepted | 17ms | 4196 KiB | ||||
28 | Accepted | 28ms | 4348 KiB | ||||
29 | Accepted | 32ms | 4448 KiB | ||||
30 | Accepted | 34ms | 4440 KiB | ||||
subtask6 | 0/50 | ||||||
31 | Accepted | 3ms | 4400 KiB | ||||
32 | Accepted | 35ms | 4556 KiB | ||||
33 | Accepted | 3ms | 2448 KiB | ||||
34 | Accepted | 3ms | 2784 KiB | ||||
35 | Accepted | 3ms | 2936 KiB | ||||
36 | Accepted | 4ms | 2964 KiB | ||||
37 | Accepted | 3ms | 2952 KiB | ||||
38 | Accepted | 3ms | 3196 KiB | ||||
39 | Accepted | 4ms | 3292 KiB | ||||
40 | Accepted | 3ms | 3364 KiB | ||||
41 | Accepted | 3ms | 3436 KiB | ||||
42 | Accepted | 3ms | 3464 KiB | ||||
43 | Accepted | 4ms | 3696 KiB | ||||
44 | Accepted | 4ms | 3908 KiB | ||||
45 | Accepted | 3ms | 3864 KiB | ||||
46 | Accepted | 3ms | 3840 KiB | ||||
47 | Accepted | 3ms | 3848 KiB | ||||
48 | Accepted | 3ms | 3852 KiB | ||||
49 | Accepted | 4ms | 4060 KiB | ||||
50 | Accepted | 8ms | 3944 KiB | ||||
51 | Accepted | 8ms | 4136 KiB | ||||
52 | Accepted | 72ms | 13456 KiB | ||||
53 | Accepted | 3ms | 4152 KiB | ||||
54 | Accepted | 3ms | 4168 KiB | ||||
55 | Accepted | 3ms | 4076 KiB | ||||
56 | Accepted | 4ms | 4072 KiB | ||||
57 | Accepted | 17ms | 4196 KiB | ||||
58 | Accepted | 28ms | 4348 KiB | ||||
59 | Accepted | 32ms | 4448 KiB | ||||
60 | Accepted | 34ms | 4440 KiB | ||||
61 | Accepted | 4ms | 4412 KiB | ||||
62 | Accepted | 6ms | 4492 KiB | ||||
63 | Accepted | 4ms | 4416 KiB | ||||
64 | Accepted | 35ms | 9116 KiB | ||||
65 | Accepted | 4ms | 4416 KiB | ||||
66 | Accepted | 4ms | 4408 KiB | ||||
67 | Accepted | 4ms | 4408 KiB | ||||
68 | Accepted | 4ms | 4408 KiB | ||||
69 | Accepted | 35ms | 4540 KiB | ||||
70 | Time limit exceeded | 476ms | 4616 KiB |