3158 2023. 02. 21 01:14:08 Ancsa Zsonglőrködés cpp11 Accepted 100/100 425ms 45000 KiB
#include <bits/stdc++.h>
/*
#include <algorithm>
#include <fstream>
#include <iostream>
#include <map>
#include <vector>
*/

using namespace std;

/*
5
1 5
4 5
5 8
5 9
1 9
*/

/*
9
1 3
2 4
8 10
1 7
2 7
2 3
9 11
3 9
3 8
*/
bool eszerint(pair <int,int> i1, pair<int, int> i2)
{
    if (i1.first!=i2.first)
       return i1.first<i2.first;
    else
       return i1.second<i2.second;
}


int main()
{

    //pair<int, int> par;
    int n;
    cin>>n;
    vector<pair<int,int>> musor(n);

    for(int i=0;i<n;i++)
    {
        cin>>musor.at(i).first>>musor.at(i).second;
    }

    sort(musor.begin(),musor.end(),eszerint);
/*
    for (int i=0;i<n;i++)
        cout<<musor.at(i).first<<"---"<<musor.at(i).second<<endl;
*/
    map<int,int> k;
    int tot = n;  //kezdetben N nap


    for (int i = 0; i < n; i++)
    {
  //      cout<<i<<"***"<<tot<<" "<<k[v[i].first]<<" "<<k[v[i].second];
        if (k[musor[i].first] > 0)
        {
            k[musor[i].first]--;

            tot--;

        }
        k[musor[i].second]++;
    //    cout<<"-->"<<k[v[i].first]<<" "<<k[v[i].second]<<endl;

    }
    cout << tot << endl;
    return 0;
}
Subtask Sum Test Verdict Time Memory
subtask1 0/0
1 Accepted 3ms 1812 KiB
2 Accepted 3ms 2056 KiB
subtask2 20/20
3 Accepted 6ms 2892 KiB
4 Accepted 104ms 14436 KiB
5 Accepted 307ms 32872 KiB
6 Accepted 358ms 38896 KiB
7 Accepted 391ms 43060 KiB
8 Accepted 393ms 43156 KiB
9 Accepted 425ms 43096 KiB
10 Accepted 389ms 43352 KiB
11 Accepted 388ms 43432 KiB
subtask3 35/35
12 Accepted 3ms 3204 KiB
13 Accepted 3ms 3348 KiB
14 Accepted 3ms 3452 KiB
15 Accepted 3ms 3448 KiB
16 Accepted 3ms 3668 KiB
17 Accepted 4ms 3788 KiB
18 Accepted 3ms 3752 KiB
19 Accepted 3ms 4160 KiB
20 Accepted 3ms 4260 KiB
subtask4 45/45
21 Accepted 4ms 4616 KiB
22 Accepted 61ms 4864 KiB
23 Accepted 284ms 34752 KiB
24 Accepted 179ms 7184 KiB
25 Accepted 400ms 45000 KiB
26 Accepted 200ms 7452 KiB
27 Accepted 402ms 44888 KiB
28 Accepted 200ms 7484 KiB
29 Accepted 382ms 44952 KiB