31562023-02-21 00:46:03AncsaZsonglőrködéscpp11Accepted 100/100444ms45664 KiB
#include <bits/stdc++.h>
/*
#include <algorithm>
#include <fstream>
#include <iostream>
#include <map>
#include <vector>
*/

/*
9
1 3
2 4
8 10
1 7
2 7
2 3
9 11
3 9
3 8
*/

using namespace std;
bool elobb(pair<int, int> x,  pair<int, int > y)
{
    if(x.second==y.second)
        return x.first<y.first;
    return  x.second<y.second;
}


int main()
{
    int N;
    vector<pair<int, int> > v;
    cin >> N;
    for (int i = 0; i < N; i++) {
        int a, b;
        cin >> a >> b;
        v.push_back({a, b});
    }

    sort(v.begin(), v.end(), elobb);
/*
    for(pair<int,int> x : v)
        cout<<x.first<<"--"<<x.second<<endl;
    cout<<endl;
*/
    map<int, int> k;
    int tot = N;  //kezdetben N nap

    //for(int i=0;i<N;i++)
      // cout<<k[v[i].first]<<" "<<k[v[i].second]<<endl;

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

            tot--;

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

    }
    cout << tot << endl;
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted3ms1852 KiB
2Accepted3ms2044 KiB
subtask220/20
3Accepted4ms2712 KiB
4Accepted104ms14572 KiB
5Accepted284ms33168 KiB
6Accepted345ms39104 KiB
7Accepted391ms43388 KiB
8Accepted404ms43692 KiB
9Accepted386ms43908 KiB
10Accepted405ms44152 KiB
11Accepted391ms43996 KiB
subtask335/35
12Accepted3ms3676 KiB
13Accepted2ms3732 KiB
14Accepted3ms3880 KiB
15Accepted3ms3972 KiB
16Accepted3ms3956 KiB
17Accepted3ms4360 KiB
18Accepted3ms4304 KiB
19Accepted3ms4460 KiB
20Accepted3ms4428 KiB
subtask445/45
21Accepted4ms4920 KiB
22Accepted61ms5756 KiB
23Accepted293ms34952 KiB
24Accepted180ms8720 KiB
25Accepted444ms44996 KiB
26Accepted201ms8764 KiB
27Accepted416ms45264 KiB
28Accepted200ms9108 KiB
29Accepted412ms45664 KiB