L1-034 點贊 分數 20

Frodnx發表於2024-08-02
// 6'22"
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    map<int,int> hash;
    for(int i = 1; i <= n; ++ i)
    {
        int k;
        cin >> k;
        for(int j = 1; j <= k; ++ j)
        {
            int tmp;
            cin >> tmp;
            hash[tmp] ++;
        }
    }
    int max = -114514;
    int num = -114514;
    for(auto h : hash)
    {
        if(h.second > max || (h.second == max && h.first > num))
        {
            max = h.second;
            num = h.first;
        }
    }
    cout << num << " " << max;
    return 0;
}

相關文章