首页 > 代码库 > CodeForces 670C Cinema

CodeForces 670C Cinema

简单题。

统计一下懂每种语言的人分别有几个,然后$O(n)$扫一遍电影就可以得到答案了。

#pragma comment(linker, "/STACK:1024000000,1024000000")#include<cstdio>#include<cstring>#include<cmath>#include<algorithm>#include<vector>#include<map>#include<set>#include<queue>#include<stack>#include<iostream>using namespace std;typedef long long LL;const double pi=acos(-1.0),eps=1e-6;void File(){    freopen("D:\\in.txt","r",stdin);    freopen("D:\\out.txt","w",stdout);}template <class T>inline void read(T &x){    char c=getchar(); x=0;    while(!isdigit(c)) c=getchar();    while(isdigit(c)) {x=x*10+c-0; c=getchar();}}const int maxn=200010;int a[maxn],b[maxn],c[maxn],n,q;map<int,int>m;int main(){    scanf("%d",&n);    for(int i=1;i<=n;i++) {int x; scanf("%d",&x),m[x]++; }    scanf("%d",&q);    for(int i=1;i<=q;i++) scanf("%d",&b[i]);    for(int i=1;i<=q;i++) scanf("%d",&c[i]);    for(int i=1;i<=q;i++) b[i]=m[b[i]],c[i]=m[c[i]];    int mx=0;    for(int i=1;i<=q;i++) mx=max(mx,b[i]);    int ans=0;    for(int i=1;i<=q;i++)    {        if(b[i]!=mx) continue;        if(c[i]<c[ans]) continue;        ans=i;    }    printf("%d\n",ans);    return 0;}

 

CodeForces 670C Cinema