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
| #include <iostream> #include <algorithm> using namespace std; const int N = 2e5 + 10; int n, m, k, tot, a[N], b[N], c[N], cnt[3 * N], langs[3 * N]; int find(int x) { return lower_bound(langs + 1, langs + 1 + k, x) - langs; } int main() { scanf("%d", &n); for (int i = 1; i <= n; ++i) scanf("%d", &a[i]), langs[++tot] = a[i]; scanf("%d", &m); for (int i = 1; i <= m; ++i) scanf("%d", &b[i]), langs[++tot] = b[i]; for (int i = 1; i <= m; ++i) scanf("%d", &c[i]), langs[++tot] = c[i]; sort(langs + 1, langs + 1 + tot); for (int i = 1; i <= tot; ++i) { langs[++k] = langs[i]; while (i < tot && langs[i + 1] == langs[i]) ++i; } for (int i = 1; i <= n; ++i) ++cnt[find(a[i])]; int ans = 0, m1 = 0, m2 = 0; for (int i = 1; i <= m; ++i) { int v1 = cnt[find(b[i])], v2 = cnt[find(c[i])]; if (v1 > m1 || (v1 == m1 && v2 > m2)) { ans = i, m1 = v1, m2 = v2; } } printf("%d\n", ans ? ans : 1); return 0; }
|