大致题意就是给出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. ADO.NET事务封装

    在数据库工具类编写的过程中,对事务的处理操作想避免各个原子操作的事务对象赋值重复操作,想对外暴露的方法为如下形式 public bool ExecuteTransition(Action Transi ...

  2. CSS3中新增的对文本和字体的设置

    文字阴影 text-shadow: 水平偏移 垂直偏移  模糊 颜色 兼容性:IE10+ <!DOCTYPE html> <html lang="en" mani ...

  3. MySQL在Windows中设置环境变量

    在桌面选择“计算机”的图标(或者是我的电脑),右键-->属性-->点击“高级系统设置” 然后选择 高级  选项点击环境变量 然后点击新建-> 变量名为MYSQL_HOME 变量值为m ...

  4. cf1176D

    题意简述:数组a经过一系列操作之后获得数组b,给你数组b,构造出一个满足条件的数组a 操作如下从左到右扫描数组a,如果是一个素数,那么把第这个素数的素数加到数组a中,例如a[1]=2那么加3到数组a当 ...

  5. LeetCode 144. 二叉树的前序遍历 (非递归)

    题目链接:https://leetcode-cn.com/problems/binary-tree-preorder-traversal/ 给定一个二叉树,返回它的 前序 遍历. /** * Defi ...

  6. ESXI | ESXI6.7如何在网页端添加用户并且赋予不同的权限

    一.首先添加一个用户 管理---用户---安全和用户 添加的新用户会显示在下面 二.给添加上的用户赋予对应权限(我这里演示赋予的是只读权限) 主机---操作---权限 三.测试登录 当用只赋予了只读权 ...

  7. 【daily】Java泛型 - 返回父类的子类

    一.栗子 public class GenericityInher { //error: Type mismatch: cannot convert from ArrayList<Child&g ...

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

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

  9. 剑指offer-面试题13-机器人的运动范围-递归法

    /* 题目: 地上有一个m行n列的方格.一个机器人从坐标(0,0)的格子开始运动, 每次可向上.下.左.右移动一格,但不能进入行坐标和列坐标之和大于k的格子. 如,当k=18时,机器人能进入(35,3 ...

  10. SOA分析浅谈

    根据百度定义:面向服务的架构(SOA)是一个组件模型,它将应用程序的不同功能单元(称为服务)进行拆分,并通过这些服务之间定义良好的接口和契约联系起来.接口是采用中立的方式进行定义的,它应该独立于实现服 ...