107972024-04-14 11:34:50AblablablaFőnökszámcpp17Wrong answer 40/100377ms65908 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
1Accepted12ms20804 KiB
2Wrong answer119ms23224 KiB
subtask25/5
3Accepted10ms21072 KiB
4Accepted10ms21372 KiB
5Accepted10ms21244 KiB
6Accepted18ms21792 KiB
subtask30/10
7Accepted8ms21880 KiB
8Accepted8ms21976 KiB
9Accepted8ms22264 KiB
10Accepted10ms22452 KiB
11Wrong answer10ms22664 KiB
12Accepted10ms22516 KiB
13Accepted14ms22548 KiB
14Accepted16ms22564 KiB
subtask410/10
15Accepted9ms22504 KiB
16Accepted10ms22580 KiB
17Accepted10ms22776 KiB
18Accepted13ms22996 KiB
19Accepted18ms23172 KiB
20Accepted30ms23500 KiB
21Accepted32ms23500 KiB
22Accepted111ms34876 KiB
subtask525/25
23Accepted9ms23224 KiB
24Accepted9ms23232 KiB
25Accepted12ms23536 KiB
26Accepted14ms23340 KiB
27Accepted64ms24416 KiB
28Accepted97ms25120 KiB
29Accepted119ms25464 KiB
30Accepted119ms25616 KiB
subtask60/50
31Accepted8ms23476 KiB
32Wrong answer119ms25468 KiB
33Accepted10ms21072 KiB
34Accepted10ms21372 KiB
35Accepted10ms21244 KiB
36Accepted18ms21792 KiB
37Accepted8ms21880 KiB
38Accepted8ms21976 KiB
39Accepted8ms22264 KiB
40Accepted10ms22452 KiB
41Wrong answer10ms22664 KiB
42Accepted10ms22516 KiB
43Accepted14ms22548 KiB
44Accepted16ms22564 KiB
45Accepted9ms22504 KiB
46Accepted10ms22580 KiB
47Accepted10ms22776 KiB
48Accepted13ms22996 KiB
49Accepted18ms23172 KiB
50Accepted30ms23500 KiB
51Accepted32ms23500 KiB
52Accepted111ms34876 KiB
53Accepted9ms23224 KiB
54Accepted9ms23232 KiB
55Accepted12ms23536 KiB
56Accepted14ms23340 KiB
57Accepted64ms24416 KiB
58Accepted97ms25120 KiB
59Accepted119ms25464 KiB
60Accepted119ms25616 KiB
61Wrong answer16ms23404 KiB
62Wrong answer14ms23412 KiB
63Wrong answer13ms23412 KiB
64Accepted61ms29244 KiB
65Wrong answer14ms23420 KiB
66Wrong answer14ms23428 KiB
67Wrong answer14ms23676 KiB
68Wrong answer14ms23680 KiB
69Wrong answer92ms25992 KiB
70Accepted377ms65908 KiB