107962024-04-14 11:34:39AblablablaFőnökszámpypy3Runtime error 0/10074ms91608 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";
    }
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Runtime error65ms87156 KiB
2Runtime error64ms87252 KiB
subtask20/5
3Runtime error64ms87624 KiB
4Runtime error64ms87896 KiB
5Runtime error64ms88008 KiB
6Runtime error64ms88200 KiB
subtask30/10
7Runtime error64ms88352 KiB
8Runtime error74ms88672 KiB
9Runtime error68ms88780 KiB
10Runtime error64ms88852 KiB
11Runtime error64ms88720 KiB
12Runtime error64ms88516 KiB
13Runtime error64ms88636 KiB
14Runtime error74ms88992 KiB
subtask40/10
15Runtime error68ms88968 KiB
16Runtime error64ms89332 KiB
17Runtime error64ms89412 KiB
18Runtime error64ms89388 KiB
19Runtime error64ms89196 KiB
20Runtime error64ms89492 KiB
21Runtime error64ms89724 KiB
22Runtime error64ms89864 KiB
subtask50/25
23Runtime error64ms89504 KiB
24Runtime error64ms90000 KiB
25Runtime error64ms90132 KiB
26Runtime error64ms89732 KiB
27Runtime error64ms90024 KiB
28Runtime error64ms90060 KiB
29Runtime error64ms89796 KiB
30Runtime error64ms90144 KiB
subtask60/50
31Runtime error72ms90352 KiB
32Runtime error72ms90548 KiB
33Runtime error64ms87624 KiB
34Runtime error64ms87896 KiB
35Runtime error64ms88008 KiB
36Runtime error64ms88200 KiB
37Runtime error64ms88352 KiB
38Runtime error74ms88672 KiB
39Runtime error68ms88780 KiB
40Runtime error64ms88852 KiB
41Runtime error64ms88720 KiB
42Runtime error64ms88516 KiB
43Runtime error64ms88636 KiB
44Runtime error74ms88992 KiB
45Runtime error68ms88968 KiB
46Runtime error64ms89332 KiB
47Runtime error64ms89412 KiB
48Runtime error64ms89388 KiB
49Runtime error64ms89196 KiB
50Runtime error64ms89492 KiB
51Runtime error64ms89724 KiB
52Runtime error64ms89864 KiB
53Runtime error64ms89504 KiB
54Runtime error64ms90000 KiB
55Runtime error64ms90132 KiB
56Runtime error64ms89732 KiB
57Runtime error64ms90024 KiB
58Runtime error64ms90060 KiB
59Runtime error64ms89796 KiB
60Runtime error64ms90144 KiB
61Runtime error70ms90256 KiB
62Runtime error74ms90212 KiB
63Runtime error74ms90672 KiB
64Runtime error74ms91100 KiB
65Runtime error68ms91264 KiB
66Runtime error72ms91076 KiB
67Runtime error74ms91136 KiB
68Runtime error72ms91608 KiB
69Runtime error72ms91296 KiB
70Runtime error68ms91288 KiB