PAT 天梯赛 L2-021. 点赞狂魔 【水】
题目链接
https://www.patest.cn/contests/gplt/L2-021
题意
给出一个若干个人名,后面给出点赞的总数,以及每个赞的标签类型,输出前三个点赞狂魔,按标签类型不同数递减排序,如果相同,则按总数递增排序
思路
用MAP 标记,统计最后有几个不同的标签类型,然后用结构体存
AC代码
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <deque>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <map>
#include <stack>
#include <set>
#include <cstdlib>
#include <ctype.h>
#include <numeric>
#include <sstream>
using namespace std;
typedef long long LL;
const double PI = 3.14159265358979323846264338327;
const double E = 2.718281828459;
const double eps = 1e-6;
const int MAXN = 0x3f3f3f3f;
const int MINN = 0xc0c0c0c0;
const int maxn = 1e2 + 5;
const int MOD = 1e9 + 7;
struct node
{
string s;
int tot;
int k;
}temp;
int comp (node x, node y)
{
if (x.tot == y.tot)
return x.k < y.k;
return x.tot > y.tot;
}
vector <node> q;
int main()
{
int n;
int i, j;
map <int, int> vis;
string s;
int k, tot, num;
cin >> n;
for (i = 0; i < n; i++)
{
vis.clear();
cin >> temp.s >> temp.k;
temp.tot = 0;
for (j = 0; j < temp.k; j++)
{
scanf("%d", &num);
if (vis[num] == 0)
temp.tot++;
vis[num]++;
}
q.push_back(temp);
}
sort (q.begin(), q.end(), comp);
temp.s = "-";
for (i = 0; i < 3; i++)
q.push_back(temp);
for (i = 0; i < 3; i++)
{
if (i)
printf(" ");
cout << q[i].s;
}
cout << endl;
}
PAT 天梯赛 L2-021. 点赞狂魔 【水】的更多相关文章
- PAT 天梯赛 L1-047. 装睡 【水】
题目链接 https://www.patest.cn/contests/gplt/L1-047 AC代码 #include <iostream> #include <cstdio&g ...
- PAT 天梯赛 L1-042. 日期格式化 【水】
题目链接 https://www.patest.cn/contests/gplt/L1-042 AC代码 #include <iostream> #include <cstdio&g ...
- PAT 天梯赛 L1-041. 寻找250 【水】
题目链接 https://www.patest.cn/contests/gplt/L1-041 AC代码 #include <iostream> #include <cstdio&g ...
- PAT 天梯赛 L1-022. 奇偶分家 【水】
题目链接 https://www.patest.cn/contests/gplt/L1-022 AC代码 #include <iostream> #include <cstdio&g ...
- PAT 天梯赛 L1-016. 查验身份证 【水】
题目链接 https://www.patest.cn/contests/gplt/L1-016 AC代码 #include <iostream> #include <cstdio&g ...
- PAT 天梯赛 L1-014. 简单题 【水】
题目链接 https://www.patest.cn/contests/gplt/L1-014 AC代码 #include <iostream> #include <cstdio&g ...
- PAT 天梯赛 L1-012. 计算指数 【水】
题目链接 https://www.patest.cn/contests/gplt/L1-012 AC代码 #include <iostream> #include <cstdio&g ...
- PAT 天梯赛 L1-010. 比较大小 【水】
题目链接 https://www.patest.cn/contests/gplt/L1-010 AC代码 #include <iostream> #include <cstdio&g ...
- PAT 天梯赛 L1-007. 念数字 【水】
题目链接 https://www.patest.cn/contests/gplt/L1-007 AC代码 #include <iostream> #include <cstdio&g ...
- PAT 天梯赛 L1-004. 计算摄氏温度 【水】
题目链接 https://www.patest.cn/contests/gplt/L1-004 AC代码 #include <iostream> #include <cstdio&g ...
随机推荐
- Shallow Heap & Retained Heap
所有包含Heap Profling功能的工具(MAT, Yourkit, JProfiler, TPTP等)都会使用到两个名词,一个是Shallow Size,另一个是 Retained Size. ...
- 椭圆曲线ECC基本概念
椭圆曲线的曲线方程是以下形式的三次方程: y2+axy+by=x3+cx2+dx+e a,b,c,d,e是满足某些简单条件的实数.定义中包含一个称为无穷点的元素,记为O 如果其上的3个点位于同一直线上 ...
- UVA 679 Dropping Balls 由小见大,分析思考 二叉树放小球,开关翻转,小球最终落下叶子编号。
A number of K balls are dropped one by one from the root of a fully binary tree structure FBT. Each ...
- NERDTree 快捷件
key description ctrl+e 打开/关闭文件浏览器 j 向下移动 k 向上移动 o 小写字母o,打开文件或者展开目录 shift+c 即大写字母C,当前选中目录作为根目录 u 上一层目 ...
- js获取object类型所有的键值对
万物皆对象,而对象完全可以用键值对来表示,所以,在js中,也是通过键值对来表示对象的,在开发中,我在修改的时候,知道属性值可以直接用点.符号来获取值,但是写common.js的时候,发现这个属性名称是 ...
- 第一百八十二节,jQuery-UI,知问前端--日历 UI
jQuery-UI,知问前端--日历 UI 学习要点: 1.调用 datepicker()方法 2.修改 datepicker()样式 3.datepicker()方法的属性 4.datepicker ...
- Unity与Android交互实现
主要参考了这篇文章: Unity与Android交互方案优化版 链接:https://www.jianshu.com/p/86b275da600e 自己的实现(unity获取内存和温度): andro ...
- Genymotion Android模拟器与fiddler 数据包拦截
Genymotion: https://www.genymotion.com/fun-zone/ https://www.genymotion.com/account/create/ cls清空记录 ...
- Unicode与UTF-8互转(c语言和lua语言)
1. 基础 1.1 ASCII码 我们知道, 在计算机内部, 全部的信息终于都表示为一个二进制的字符串. 每个二进制 位(bit)有0和1两种状态, 因此八个二进制位就能够组合出 256种状态, 这被 ...
- 转:: 刺鸟:用python来开发webgame服务端(3)
来源:http://ciniao.me/article.php?id=11 --------------- 刺鸟原创文章,转载请注明出处 在之前的准备工作中,我们已经建立了一个socket服务器 ...