3966 2023. 03. 07 06:39:45 Ancsa Zsonglőrködés cpp11 Accepted 100/100 554ms 61008 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;
}
Subtask Sum Test Verdict Time Memory
subtask1 0/0
1 Accepted 3ms 1808 KiB
2 Accepted 2ms 2000 KiB
subtask2 20/20
3 Accepted 6ms 2752 KiB
4 Accepted 125ms 19308 KiB
5 Accepted 354ms 44720 KiB
6 Accepted 442ms 53164 KiB
7 Accepted 504ms 59172 KiB
8 Accepted 504ms 59224 KiB
9 Accepted 503ms 59384 KiB
10 Accepted 510ms 59524 KiB
11 Accepted 547ms 59452 KiB
subtask3 35/35
12 Accepted 3ms 3316 KiB
13 Accepted 3ms 3564 KiB
14 Accepted 3ms 3824 KiB
15 Accepted 3ms 3840 KiB
16 Accepted 3ms 3964 KiB
17 Accepted 3ms 4112 KiB
18 Accepted 3ms 4048 KiB
19 Accepted 3ms 4004 KiB
20 Accepted 3ms 4008 KiB
subtask4 45/45
21 Accepted 6ms 4364 KiB
22 Accepted 57ms 3956 KiB
23 Accepted 395ms 46236 KiB
24 Accepted 165ms 4144 KiB
25 Accepted 550ms 60444 KiB
26 Accepted 185ms 4392 KiB
27 Accepted 554ms 60604 KiB
28 Accepted 182ms 4784 KiB
29 Accepted 501ms 61008 KiB