Cinema (CodeForces670C) 离散化
#include<bits/stdc++.h> const int N = 1e6+9; using namespace std; int n, m, a[N], b[N], c[N], d[N], cnt[N]; struct Node { int x, y, z; } node[N]; bool cmp(Node a, Node b) { if (a.x != b.x) return a.x > b.x; else return a.y > b.y; } int main() { cin >> n; for (int i = 1; i <= n; i++) scanf("%d", &a[i]), d[i] = a[i]; cin >> m; for (int i = 1; i <= m; i++) scanf("%d", &b[i]), d[n + i] = b[i]; for (int i = 1; i <= m; i++) scanf("%d", &c[i]), d[n + m + i] = c[i]; sort(d + 1, d + n + m + m + 1); int mm = unique(d + 1, d + n + m + m + 1) - d - 1; for (int i = 1; i <= n; i++) a[i] = lower_bound(d + 1, d + mm + 1, a[i]) - d, cnt[a[i]]++; for (int i = 1; i <= m; i++) node[i].x = cnt[lower_bound(d + 1, d + mm + 1, b[i]) - d], node[i].z = i; for (int i = 1; i <= m; i++) node[i].y = cnt[lower_bound(d + 1, d + mm + 1, c[i]) - d]; sort(node + 1, node + m + 1, cmp); cout << node[1].z; return 0; }