离散化 WA求助
查看原帖
离散化 WA求助
523541
Onana_in_XMFLS楼主2021/10/22 22:16
#include <bits/stdc++.h>
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
#define mem(l,val) memset((l),(val),(sizeof(l)))
using namespace std;
const int INF = 2147483647;
const int S = 5+200000;
LL n,m,down,mnum = -INF,mfirst = -INF,msecond = -INF,dow,t[S],tmp[S],a[S],b[S],c[S],cnt[S];
inline void discrete()
{
	sort(t+1,t+dow+1);
	for(LL i = 1;i <= n;++i)
		if(i == 1 || t[i] != t[i-1]) a[++down] = t[i];
}
inline LL query(LL x) {return lower_bound(a+1,a+down+1,x)-a;}
int main(int argc,char *argv[])
{ 
	//freopen("data.in","r",stdin);
	//freopen("data.out","w",stdout);	
	scanf("%lld",&n);
	for(LL i = 1;i <= n;++i) 
		scanf("%lld",&tmp[i]),t[++dow] = tmp[i];
	scanf("%lld",&m);
	for(LL i = 1;i <= m;++i) 
		scanf("%lld",&b[i]),t[++dow] = b[i];
	for(LL i = 1;i <= m;++i) 
		scanf("%lld",&c[i]),t[++dow] = c[i];
	discrete();
	for(LL i = 1;i <= n;++i) ++cnt[query(tmp[i])];
	for(LL i = 1;i <= m;++i)
	{
		LL tf = cnt[query(b[i])],ts = cnt[query(c[i])];
		if(tf > mfirst || (tf == mfirst && ts > msecond))
			mnum = i,mfirst = tf,msecond = ts;
	}
	printf("%lld\n",mnum);
	return 0;
}   
2021/10/22 22:16
加载中...