1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include <iostream>
#include <set>

using namespace std;

int main(int argc, char const *argv[])
{
    int k, n, a, z, d;
    long long res;
    set<int> s;

    cin >> k >> res;

    for (int i=1; i<k; i++) {
        cin >> n;
        z = 0;
        d = 0;
        s = {};
        for  (int j=0; j<n; j++) {
            cin >> a;
            if (a == 0) z++;
            else {
                if (s.find(a) == s.end()) s.insert(a);
                else d++;
            }
        }
        if (res < z + s.size()) res = z + s.size();
        res += d;
    }

    cout << res;

    return 0;
}