107482024-04-11 07:27:41zsebiFőnökszámcpp14Time limit exceeded 5/100500ms16728 KiB
#include <iostream>
#include <queue>
#include <map>
#include <set>
#define ll long long
using namespace std;
struct alk
{
    ll els, mas;
};
priority_queue<alk>que;
bool operator<(const alk a, const alk b)
{
    if (a.els > b.els)return true;
    else if (a.els == b.els && a.mas > b.mas)return true;
    return false;
}
struct alk2
{
    ll els, mas;
};
/*priority_queue<alk2>que2;
bool operator<(const alk2 a, const alk2 b)
{
    if (a.els < b.els)return true;
    else if (a.els == b.els && a.mas < b.mas)return true;
    return false;
}*/
map<ll,set<ll> >mp;
int main() {
    ll n;
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        ll a, b;
        cin >> a >> b;
       /* if (!que2.empty() && (que2.top().els <= a || que2.top().mas <= b))
        {
            que2.push({ a, b });
            que.push({ a,b });
        }
        if (que2.empty())
        {
            que2.push({ a,b });
            que.push({ a,b });
        }*/
        bool ok = false;
        mp[a].insert(b);
        for (auto& e : mp)
        {
            if (e.first > a)
            {
               auto it= e.second.upper_bound(b);
               if (it != e.second.end())
               {
                   ok = true;
                   break;
               }
            }
        }
        if (!ok)
        {
            que.push({ a,b });
            while (!que.empty() && a > que.top().els && b > que.top().mas) {
                que.pop();
            }
        }


        cout << que.size() << "\n";
    }
    return 0;
}

SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted3ms1880 KiB
2Time limit exceeded500ms2640 KiB
subtask25/5
3Accepted3ms2268 KiB
4Accepted3ms2492 KiB
5Accepted7ms2924 KiB
6Accepted319ms4712 KiB
subtask30/10
7Accepted3ms3108 KiB
8Accepted3ms3212 KiB
9Accepted3ms3456 KiB
10Accepted3ms3532 KiB
11Wrong answer4ms3664 KiB
12Wrong answer8ms3928 KiB
13Wrong answer41ms4560 KiB
14Wrong answer108ms5312 KiB
subtask40/10
15Accepted3ms3872 KiB
16Accepted3ms3996 KiB
17Accepted4ms4128 KiB
18Accepted17ms4520 KiB
19Accepted85ms5480 KiB
20Time limit exceeded449ms4680 KiB
21Time limit exceeded474ms4740 KiB
22Accepted273ms16728 KiB
subtask50/25
23Wrong answer4ms4448 KiB
24Wrong answer8ms4784 KiB
25Wrong answer41ms5660 KiB
26Wrong answer109ms6156 KiB
27Time limit exceeded428ms5244 KiB
28Time limit exceeded462ms5364 KiB
29Time limit exceeded465ms5316 KiB
30Time limit exceeded474ms5504 KiB
subtask60/50
31Accepted3ms5148 KiB
32Time limit exceeded500ms5708 KiB
33Accepted3ms2268 KiB
34Accepted3ms2492 KiB
35Accepted7ms2924 KiB
36Accepted319ms4712 KiB
37Accepted3ms3108 KiB
38Accepted3ms3212 KiB
39Accepted3ms3456 KiB
40Accepted3ms3532 KiB
41Wrong answer4ms3664 KiB
42Wrong answer8ms3928 KiB
43Wrong answer41ms4560 KiB
44Wrong answer108ms5312 KiB
45Accepted3ms3872 KiB
46Accepted3ms3996 KiB
47Accepted4ms4128 KiB
48Accepted17ms4520 KiB
49Accepted85ms5480 KiB
50Time limit exceeded449ms4680 KiB
51Time limit exceeded474ms4740 KiB
52Accepted273ms16728 KiB
53Wrong answer4ms4448 KiB
54Wrong answer8ms4784 KiB
55Wrong answer41ms5660 KiB
56Wrong answer109ms6156 KiB
57Time limit exceeded428ms5244 KiB
58Time limit exceeded462ms5364 KiB
59Time limit exceeded465ms5316 KiB
60Time limit exceeded474ms5504 KiB
61Wrong answer39ms5740 KiB
62Wrong answer46ms5964 KiB
63Wrong answer39ms5784 KiB
64Accepted130ms11320 KiB
65Wrong answer39ms5680 KiB
66Wrong answer39ms5652 KiB
67Wrong answer41ms5808 KiB
68Wrong answer39ms5652 KiB
69Time limit exceeded474ms6632 KiB
70Time limit exceeded465ms5844 KiB