CodeForces_670C Cinema ( 模拟 )

文章目录

题目连接 vj or cf

题意

n 个科学家每个科学家对应一门语言,
m 个电影, 从角标 1 开始到m,
接下来的第一行是对应角标电影的 主字幕语言, 第二行是对应角标的 副字幕语言,
如果主字幕出现科学家的语言, 他会非常满意; 如果副字幕出现, 他会几乎满意; 如果不出现, 会不满意.
输出达到最大满意人数的电影编号

题解

画下图, 很清晰的思路
统计最大满意人数, 再在最大满意人数中统计几乎满意人数, 维护最大人数的同时记录电影编号
在这里插入图片描述

代码

#include <bits/stdc++.h> 
using namespace std; 
#define rg register 
#define sc scanf 
#define pf printf 
typedef long long ll; 

const int RANGE = 2e5+10;

int n;
	map<int,int> tot;
int	m,
	a[RANGE], b[RANGE],
	tmp;

int main ( ) {  // freopen( "F:\\in\\.txt" , "r" , stdin ); 

	sc( "%d", &n );
	for ( int i = 0; i < n; ++i ) {
		sc( "%d", &tmp );
		tot[tmp]++;
	}

	sc( "%d", &m );

	int maxTot = -0x3f3f3f3f,
		maxMovie = 1;
	for ( int i = 0; i < m; ++i ) {
		sc( "%d", &a[i] );
		if ( tot[a[i]] > maxTot ) {
			maxTot = tot[a[i]];
			maxMovie = i+1;
		}
	}

	int _maxTot = -0x3f3f3f3f;
	for ( int i = 0; i < m; ++i ) {
		sc( "%d", &b[i] ); // 其实这里是没有必要存的, 也懒得来改了
        if ( tot[a[i]]==maxTot ) {
            if ( tot[b[i]]>_maxTot ) {
                _maxTot = tot[b[i]];
                maxMovie = i+1;
            }
        }
	}

	pf( "%d\n", maxMovie );

	return 0 ; 
} 
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值