【题目链接】
http://codeforces.com/contest/670/problem/C
【算法】
离散化
【代码】
#include<bits/stdc++.h>
using namespace std;
#define MAXN 200010 int n,m,pos,mx = -,nx = -,len,i,rkb,rkc;
int a[MAXN],b[MAXN],c[MAXN],s[MAXN<<],tmp[MAXN<<]; template <typename T> inline void read(T &x)
{
int f = ; x = ;
char c = getchar();
for (; !isdigit(c); c = getchar()) { if (c == '-') f = -f; }
for (; isdigit(c); c = getchar()) x = (x << ) + (x << ) + c - '';
x *= f;
}
template <typename T> inline void write(T x)
{
if (x < )
{
putchar('-');
x = -x;
}
if (x > ) write(x/);
putchar(x%+'');
}
template <typename T> inline void writeln(T x)
{
write(x);
puts("");
} int main()
{ read(n);
for (i = ; i <= n; i++)
{
read(a[i]);
tmp[++len] = a[i];
}
read(m);
for (i = ; i <= m; i++)
{
read(b[i]);
tmp[++len] = b[i];
}
for (i = ; i <= m; i++)
{
read(c[i]);
tmp[++len] = c[i];
}
sort(tmp+,tmp+n+*m+);
len = unique(tmp+,tmp+n+*m+) - tmp;
for (i = ; i <= n; i++) s[lower_bound(tmp+,tmp+len+,a[i])-tmp]++;
for (i = ; i <= m; i++)
{
rkb = lower_bound(tmp+,tmp+len+,b[i]) - tmp;
rkc = lower_bound(tmp+,tmp+len+,c[i]) - tmp;
if (s[rkb] > mx)
{
pos = i;
mx = s[rkb];
nx = s[rkc];
} else if (s[rkb] == mx && s[rkc] > nx)
{
pos = i;
nx = s[rkc];
}
}
writeln(pos); return ; }