31582023-02-21 01:14:08AncsaZsonglőrködéscpp11Accepted 100/100425ms45000 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;
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted3ms1812 KiB
2Accepted3ms2056 KiB
subtask220/20
3Accepted6ms2892 KiB
4Accepted104ms14436 KiB
5Accepted307ms32872 KiB
6Accepted358ms38896 KiB
7Accepted391ms43060 KiB
8Accepted393ms43156 KiB
9Accepted425ms43096 KiB
10Accepted389ms43352 KiB
11Accepted388ms43432 KiB
subtask335/35
12Accepted3ms3204 KiB
13Accepted3ms3348 KiB
14Accepted3ms3452 KiB
15Accepted3ms3448 KiB
16Accepted3ms3668 KiB
17Accepted4ms3788 KiB
18Accepted3ms3752 KiB
19Accepted3ms4160 KiB
20Accepted3ms4260 KiB
subtask445/45
21Accepted4ms4616 KiB
22Accepted61ms4864 KiB
23Accepted284ms34752 KiB
24Accepted179ms7184 KiB
25Accepted400ms45000 KiB
26Accepted200ms7452 KiB
27Accepted402ms44888 KiB
28Accepted200ms7484 KiB
29Accepted382ms44952 KiB