18682022-12-06 11:05:33kdbLegtöbb unoka (80 pont)cpp11Accepted 80/804ms5328 KiB
#include <iostream>
#include <vector>
using namespace std;

int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);

    int n, m;
    cin >> n >> m;
    vector<vector<int>>vec(n + 1);
    vector<int>vec2(n + 1);
    for (size_t i = 0; i < m; i++)
    {
        int a, b;
        cin >> a >> b;
        vec[a].push_back(b);
        vec2[a]++;
    }
    int mk = 0, mh = 0, lh = 0;
    for (size_t i = 1; i < n; i++)
    {
        for (int j : vec[i])
        {
            lh += vec2[j];
        }
        if (lh > mh)
        {
            mk = i;
            mh = lh;
        }
        lh = 0;
    }
    if (mh == 0) cout << -1 << endl;
    else cout << mk << " " << mh << endl;
}
/*
10 9
1 2
2 4
1 3
3 5
5 7
5 8
5 9
3 6
6 10
-3 4
*/
SubtaskSumTestVerdictTimeMemory
base80/80
1Accepted0/03ms1956 KiB
2Accepted0/04ms2836 KiB
3Accepted4/42ms2256 KiB
4Accepted4/42ms2488 KiB
5Accepted4/44ms3212 KiB
6Accepted4/44ms3468 KiB
7Accepted4/42ms2724 KiB
8Accepted4/42ms2852 KiB
9Accepted4/44ms3532 KiB
10Accepted4/44ms3824 KiB
11Accepted4/44ms4076 KiB
12Accepted4/44ms3852 KiB
13Accepted4/44ms4152 KiB
14Accepted4/44ms4156 KiB
15Accepted4/44ms4128 KiB
16Accepted4/44ms4128 KiB
17Accepted4/44ms4300 KiB
18Accepted4/44ms4380 KiB
19Accepted2/22ms4196 KiB
20Accepted2/22ms4400 KiB
21Accepted3/32ms4604 KiB
22Accepted3/33ms4580 KiB
23Accepted3/34ms5120 KiB
24Accepted3/34ms5328 KiB