大致题意就是给出N行M列的元素,找出出现次数最多的元素并输出。

#include<iostream>
#include<unordered_map>
using namespace std; int main() {
unordered_map<int,int> mp;
int m,n;
cin>>m>>n;
for(int i = ; i < n; ++i) {
for(int j = ; j < m; ++j) {
int t;
scanf("%d",&t); //可能会超时,把cin改为scanf
mp[t]++;
}
}
int max = -,ans = ;
for(auto it = mp.begin(); it != mp.end(); ++it) {
if(max < it->second) {
max = it->second;
ans = it->first;
} }
cout<<ans;
return ;
}

1054 The Dominant Color的更多相关文章

  1. PAT 1054 The Dominant Color

    1054 The Dominant Color (20 分)   Behind the scenes in the computer's memory, color is always talked ...

  2. PAT 甲级 1054 The Dominant Color (20 分)

    1054 The Dominant Color (20 分) Behind the scenes in the computer's memory, color is always talked ab ...

  3. PAT 1054 The Dominant Color[简单][运行超时的问题]

    1054 The Dominant Color (20)(20 分) Behind the scenes in the computer's memory, color is always talke ...

  4. pat 1054 The Dominant Color(20 分)

    1054 The Dominant Color(20 分) Behind the scenes in the computer's memory, color is always talked abo ...

  5. PAT 甲级 1054 The Dominant Color (20 分)(简单题)

    1054 The Dominant Color (20 分)   Behind the scenes in the computer's memory, color is always talked ...

  6. 1054. The Dominant Color (20)

    时间限制 100 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue Behind the scenes in the compute ...

  7. PAT 甲级 1054 The Dominant Color

    https://pintia.cn/problem-sets/994805342720868352/problems/994805422639136768 Behind the scenes in t ...

  8. 1054 The Dominant Color (20)(20 分)

    Behind the scenes in the computer's memory, color is always talked about as a series of 24 bits of i ...

  9. PAT (Advanced Level) Practice 1054 The Dominant Color (20 分)

    Behind the scenes in the computer's memory, color is always talked about as a series of 24 bits of i ...

  10. 1054 The Dominant Color (20分)(水)

    Behind the scenes in the computer's memory, color is always talked about as a series of 24 bits of i ...

随机推荐

  1. Java Web Servlet知识点讲解(一)

    一.Web应用架构 如图所示: HTTP协议:一个简单的请求一响应协议,通常运行在TCP之上,它指定了客户端可能发送给服务器什么样的信息以及得到什么样的响应. JDBC:Java语言中用来规范客户端程 ...

  2. python数据类型(总结篇)

    世界上最容易的事是坚持,最难的事也是坚持.开通博客园已两月有余,但实际上笔者本人的活跃度非常低,痛定思痛,自己选的路含泪也要走下去,继续坚持! 本文承接前几个月的python数据类型系列,完成对字典与 ...

  3. honeywell1900扫描枪的使用说明

    霍尼韦尔1900扫描枪驱动是honeywell1900扫描枪的USB驱动,就是扫描枪usb转com,如果你的系统是32位的,就直接运行Install_x86.bat,如果是64位的,就运行Instal ...

  4. 【笔记】机器学习 - 李宏毅 - 8 - Backpropagation

    反向传播 反向传播主要用到是链式法则. 概念: 损失函数Loss Function是定义在单个训练样本上的,也就是一个样本的误差. 代价函数Cost Function是定义在整个训练集上的,也就是所有 ...

  5. 初识Mybatis和一些配置和练习

    什么是Mybatis: MyBatis 是一款优秀的持久层框架,它支持定制化 SQL.存储过程以及高级映射. MyBatis 避免了几乎所有的 JDBC 代码和手动设置参数以及获取结果集. MyBat ...

  6. TCP 协议快被淘汰了,UDP 协议才是新世代的未来?

    TCP 协议可以说是今天互联网的基石,作为可靠的传输协议,在今天几乎所有的数据都会通过 TCP 协议传输,然而 TCP 在设计之初没有考虑到现今复杂的网络环境,当你在地铁上或者火车上被断断续续的网络折 ...

  7. Java基础汇总2019

    1.事务的ACID性: (1)原子性:要么做,要么都不做.程序操作执行未成功,则所做的更改会被撤销: (2)一致性:比如转账,a转给b一百元,则a的账户少100,b的账户多100,前后数据要一致: ( ...

  8. VS打包程序步骤

    1.下载打包的程序 2.在你的程序里面安装打包的项目 3.添加项目输出 4.为项目添加必要的文件 双击前面建立好的主输出 一般文件为一些配置文件(如使用Nlog写日志,需要添加Nlog的配置文件)和图 ...

  9. vue自学入门-4(vue slot)

    vue自学入门-1(Windows下搭建vue环境) vue自学入门-2(vue创建项目) vue自学入门-3(vue第一个例子) vue自学入门-4(vue slot) vue自学入门-5(vuex ...

  10. DVA知识集合

    react与dva 原文地址:https://github.com/dvajs/dva-knowledgemap 1.变量声明 const DELAY = 1000 let count = 0 cou ...