10796 | 2024-04-14 11:34:39 | Ablablabla | Főnökszám | pypy3 | Runtime error 0/100 | 74ms | 91608 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 | Runtime error | 65ms | 87156 KiB | ||||
2 | Runtime error | 64ms | 87252 KiB | ||||
subtask2 | 0/5 | ||||||
3 | Runtime error | 64ms | 87624 KiB | ||||
4 | Runtime error | 64ms | 87896 KiB | ||||
5 | Runtime error | 64ms | 88008 KiB | ||||
6 | Runtime error | 64ms | 88200 KiB | ||||
subtask3 | 0/10 | ||||||
7 | Runtime error | 64ms | 88352 KiB | ||||
8 | Runtime error | 74ms | 88672 KiB | ||||
9 | Runtime error | 68ms | 88780 KiB | ||||
10 | Runtime error | 64ms | 88852 KiB | ||||
11 | Runtime error | 64ms | 88720 KiB | ||||
12 | Runtime error | 64ms | 88516 KiB | ||||
13 | Runtime error | 64ms | 88636 KiB | ||||
14 | Runtime error | 74ms | 88992 KiB | ||||
subtask4 | 0/10 | ||||||
15 | Runtime error | 68ms | 88968 KiB | ||||
16 | Runtime error | 64ms | 89332 KiB | ||||
17 | Runtime error | 64ms | 89412 KiB | ||||
18 | Runtime error | 64ms | 89388 KiB | ||||
19 | Runtime error | 64ms | 89196 KiB | ||||
20 | Runtime error | 64ms | 89492 KiB | ||||
21 | Runtime error | 64ms | 89724 KiB | ||||
22 | Runtime error | 64ms | 89864 KiB | ||||
subtask5 | 0/25 | ||||||
23 | Runtime error | 64ms | 89504 KiB | ||||
24 | Runtime error | 64ms | 90000 KiB | ||||
25 | Runtime error | 64ms | 90132 KiB | ||||
26 | Runtime error | 64ms | 89732 KiB | ||||
27 | Runtime error | 64ms | 90024 KiB | ||||
28 | Runtime error | 64ms | 90060 KiB | ||||
29 | Runtime error | 64ms | 89796 KiB | ||||
30 | Runtime error | 64ms | 90144 KiB | ||||
subtask6 | 0/50 | ||||||
31 | Runtime error | 72ms | 90352 KiB | ||||
32 | Runtime error | 72ms | 90548 KiB | ||||
33 | Runtime error | 64ms | 87624 KiB | ||||
34 | Runtime error | 64ms | 87896 KiB | ||||
35 | Runtime error | 64ms | 88008 KiB | ||||
36 | Runtime error | 64ms | 88200 KiB | ||||
37 | Runtime error | 64ms | 88352 KiB | ||||
38 | Runtime error | 74ms | 88672 KiB | ||||
39 | Runtime error | 68ms | 88780 KiB | ||||
40 | Runtime error | 64ms | 88852 KiB | ||||
41 | Runtime error | 64ms | 88720 KiB | ||||
42 | Runtime error | 64ms | 88516 KiB | ||||
43 | Runtime error | 64ms | 88636 KiB | ||||
44 | Runtime error | 74ms | 88992 KiB | ||||
45 | Runtime error | 68ms | 88968 KiB | ||||
46 | Runtime error | 64ms | 89332 KiB | ||||
47 | Runtime error | 64ms | 89412 KiB | ||||
48 | Runtime error | 64ms | 89388 KiB | ||||
49 | Runtime error | 64ms | 89196 KiB | ||||
50 | Runtime error | 64ms | 89492 KiB | ||||
51 | Runtime error | 64ms | 89724 KiB | ||||
52 | Runtime error | 64ms | 89864 KiB | ||||
53 | Runtime error | 64ms | 89504 KiB | ||||
54 | Runtime error | 64ms | 90000 KiB | ||||
55 | Runtime error | 64ms | 90132 KiB | ||||
56 | Runtime error | 64ms | 89732 KiB | ||||
57 | Runtime error | 64ms | 90024 KiB | ||||
58 | Runtime error | 64ms | 90060 KiB | ||||
59 | Runtime error | 64ms | 89796 KiB | ||||
60 | Runtime error | 64ms | 90144 KiB | ||||
61 | Runtime error | 70ms | 90256 KiB | ||||
62 | Runtime error | 74ms | 90212 KiB | ||||
63 | Runtime error | 74ms | 90672 KiB | ||||
64 | Runtime error | 74ms | 91100 KiB | ||||
65 | Runtime error | 68ms | 91264 KiB | ||||
66 | Runtime error | 72ms | 91076 KiB | ||||
67 | Runtime error | 74ms | 91136 KiB | ||||
68 | Runtime error | 72ms | 91608 KiB | ||||
69 | Runtime error | 72ms | 91296 KiB | ||||
70 | Runtime error | 68ms | 91288 KiB |