39662023-03-07 06:39:45AncsaZsonglőrködéscpp11Accepted 100/100554ms61008 KiB
#include <bits/stdc++.h>

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(Interv i1, Interv i2)
{
    if (i1.e!=i2.e)
       return i1.e<i2.e;
    else
       return i1.v<i2.v;
}
*/


int main()
{
    int n;
    cin>>n;
    map <int,int> eleje, vege;
    pair<int, int> musor;
    //vector<pair<int, int>> m(n);

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

        eleje[musor.first]++;
        vege[musor.second]++;
    }


    //sort(musor.begin(),musor.end(),eszerint);
/*
    for(pair<int,int> x: m)
        cout<<x.first<<"-"<<x.second<<endl;
*/
    int napok=n;
/*
    for(int i=0;i<m.size();i++)
    {
        eleje[m.at(i).first]++;
        vege[m.at(i).second]++;

    }
*/
/*
    cout<<"eleje:\n";
    for(pair<int,int> x:eleje)
       cout<<x.first<<" "<<x.second<<endl;

    cout<<"vege:" <<endl;
    for(pair<int,int> x:vege)
       cout<<x.first<<" "<<x.second<<endl;
*/
    for(pair<int,int> x:eleje)
    {
       //cout<<x<<"\t"<<x.first<<"  "<<vege[x.first]<<"  "<<min(vege[x.first],x.first)<<endl;
       if(min(vege[x.first],x.second)>0)
             napok-=min(x.second,vege[x.first]);
    }

    cout<<napok;
    return 0;
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted3ms1808 KiB
2Accepted2ms2000 KiB
subtask220/20
3Accepted6ms2752 KiB
4Accepted125ms19308 KiB
5Accepted354ms44720 KiB
6Accepted442ms53164 KiB
7Accepted504ms59172 KiB
8Accepted504ms59224 KiB
9Accepted503ms59384 KiB
10Accepted510ms59524 KiB
11Accepted547ms59452 KiB
subtask335/35
12Accepted3ms3316 KiB
13Accepted3ms3564 KiB
14Accepted3ms3824 KiB
15Accepted3ms3840 KiB
16Accepted3ms3964 KiB
17Accepted3ms4112 KiB
18Accepted3ms4048 KiB
19Accepted3ms4004 KiB
20Accepted3ms4008 KiB
subtask445/45
21Accepted6ms4364 KiB
22Accepted57ms3956 KiB
23Accepted395ms46236 KiB
24Accepted165ms4144 KiB
25Accepted550ms60444 KiB
26Accepted185ms4392 KiB
27Accepted554ms60604 KiB
28Accepted182ms4784 KiB
29Accepted501ms61008 KiB