10798 | 2024-04-14 11:39:15 | Ablablabla | Főnökszám | cpp17 | Accepted 100/100 | 384ms | 65612 KiB |
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 5;
int akt = 0;
set<int> a;
multiset<int> b[MAXN];
void torol(int x, int y){
auto it = a.lower_bound(x);
while(it != a.begin()){
it--;
int ert = *it;
auto itB = b[ert].begin();
while(itB != b[ert].end() && *itB < y){
akt--;
itB = b[ert].erase(itB);
}
if(b[ert].empty()){
a.erase(ert);
it = a.lower_bound(x);
} else{
break;
}
}
}
void beszur(int x, int y){
akt++;
a.insert(x);
b[x].insert(y);
}
void berak(int x, int y){
auto it = a.upper_bound(x);
if(it == a.end()){
beszur(x, y);
} else{
int ert = *it;
if(*b[ert].rbegin() <= y){
beszur(x, y);
}
}
}
int main()
{
int n;
cin >> n;
vector<int> alapA(n), alapB(n), nyom(n);
for(int i = 0; i < n; i++){
cin >> alapA[i] >> alapB[i];
nyom[i] = alapA[i];
}
sort(nyom.begin(), nyom.end());
nyom.erase(unique(nyom.begin(), nyom.end()), nyom.end());
for(int &x : alapA){
x = lower_bound(nyom.begin(), nyom.end(), x) - nyom.begin();
}
for(int i = 0; i < n; i++){
torol(alapA[i], alapB[i]);
berak(alapA[i], alapB[i]);
cout << akt << "\n";
}
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Accepted | 12ms | 20536 KiB | ||||
2 | Accepted | 119ms | 22948 KiB | ||||
subtask2 | 5/5 | ||||||
3 | Accepted | 10ms | 21020 KiB | ||||
4 | Accepted | 9ms | 21232 KiB | ||||
5 | Accepted | 9ms | 21100 KiB | ||||
6 | Accepted | 18ms | 21584 KiB | ||||
subtask3 | 10/10 | ||||||
7 | Accepted | 10ms | 21672 KiB | ||||
8 | Accepted | 9ms | 21640 KiB | ||||
9 | Accepted | 10ms | 21780 KiB | ||||
10 | Accepted | 10ms | 22072 KiB | ||||
11 | Accepted | 10ms | 22172 KiB | ||||
12 | Accepted | 10ms | 22268 KiB | ||||
13 | Accepted | 14ms | 22480 KiB | ||||
14 | Accepted | 16ms | 22604 KiB | ||||
subtask4 | 10/10 | ||||||
15 | Accepted | 9ms | 22764 KiB | ||||
16 | Accepted | 10ms | 22740 KiB | ||||
17 | Accepted | 10ms | 22816 KiB | ||||
18 | Accepted | 10ms | 22824 KiB | ||||
19 | Accepted | 18ms | 23048 KiB | ||||
20 | Accepted | 30ms | 23368 KiB | ||||
21 | Accepted | 30ms | 23380 KiB | ||||
22 | Accepted | 111ms | 34616 KiB | ||||
subtask5 | 25/25 | ||||||
23 | Accepted | 8ms | 23028 KiB | ||||
24 | Accepted | 9ms | 23028 KiB | ||||
25 | Accepted | 14ms | 23104 KiB | ||||
26 | Accepted | 14ms | 23020 KiB | ||||
27 | Accepted | 63ms | 24164 KiB | ||||
28 | Accepted | 97ms | 24764 KiB | ||||
29 | Accepted | 118ms | 25284 KiB | ||||
30 | Accepted | 120ms | 25308 KiB | ||||
subtask6 | 50/50 | ||||||
31 | Accepted | 9ms | 23196 KiB | ||||
32 | Accepted | 125ms | 25360 KiB | ||||
33 | Accepted | 10ms | 21020 KiB | ||||
34 | Accepted | 9ms | 21232 KiB | ||||
35 | Accepted | 9ms | 21100 KiB | ||||
36 | Accepted | 18ms | 21584 KiB | ||||
37 | Accepted | 10ms | 21672 KiB | ||||
38 | Accepted | 9ms | 21640 KiB | ||||
39 | Accepted | 10ms | 21780 KiB | ||||
40 | Accepted | 10ms | 22072 KiB | ||||
41 | Accepted | 10ms | 22172 KiB | ||||
42 | Accepted | 10ms | 22268 KiB | ||||
43 | Accepted | 14ms | 22480 KiB | ||||
44 | Accepted | 16ms | 22604 KiB | ||||
45 | Accepted | 9ms | 22764 KiB | ||||
46 | Accepted | 10ms | 22740 KiB | ||||
47 | Accepted | 10ms | 22816 KiB | ||||
48 | Accepted | 10ms | 22824 KiB | ||||
49 | Accepted | 18ms | 23048 KiB | ||||
50 | Accepted | 30ms | 23368 KiB | ||||
51 | Accepted | 30ms | 23380 KiB | ||||
52 | Accepted | 111ms | 34616 KiB | ||||
53 | Accepted | 8ms | 23028 KiB | ||||
54 | Accepted | 9ms | 23028 KiB | ||||
55 | Accepted | 14ms | 23104 KiB | ||||
56 | Accepted | 14ms | 23020 KiB | ||||
57 | Accepted | 63ms | 24164 KiB | ||||
58 | Accepted | 97ms | 24764 KiB | ||||
59 | Accepted | 118ms | 25284 KiB | ||||
60 | Accepted | 120ms | 25308 KiB | ||||
61 | Accepted | 16ms | 23496 KiB | ||||
62 | Accepted | 14ms | 23392 KiB | ||||
63 | Accepted | 13ms | 23648 KiB | ||||
64 | Accepted | 61ms | 29216 KiB | ||||
65 | Accepted | 14ms | 23580 KiB | ||||
66 | Accepted | 14ms | 23520 KiB | ||||
67 | Accepted | 14ms | 23516 KiB | ||||
68 | Accepted | 14ms | 23520 KiB | ||||
69 | Accepted | 94ms | 25580 KiB | ||||
70 | Accepted | 384ms | 65612 KiB |