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 35 36 37 38 39 40 41 42 43
| #include <bits/stdc++.h> #define ouo ios_base::sync_with_stdio(false), cin.tie(0) #define ll long long #define db double using namespace std;
int main() { int k, n; cin >> k >> n; int arr[k]; int goods[1005] = {0}; for (int i = 0; i < k; i++) { cin >> arr[i]; goods[arr[i]]++; } int mx = 0, favorite = -1; for (int i = 0; i < k; i++) { if (goods[arr[i]] > mx) { mx = goods[arr[i]]; favorite = arr[i]; } }
int shop[n]; for (int i = 0; i < n; i++) cin >> shop[i];
int mn = INT_MAX, flag = -1; for (int i = 0; i < n; i++) { int val = 0; for (int q = 0; q < shop[i]; q++) { int quetion; cin >> quetion; val += goods[quetion]; } if (val < mn) { mn = val; flag = i; } }
cout << favorite << " " << flag + 1; }
|