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 ...
随机推荐
- linq基础,正则表达式,.net相关
声明扩展方法的步骤:类必须是static,方法是static,第一个参数是被扩展的对象,前面标注this.使用扩展方法的时候必须保证扩展方法类已经在当前代码中using. LINQ:将int数组中大 ...
- IOS设计模式的六大设计原则之迪米特法则(LOD,Law Of Demeter)
定义 狭义的迪米特法则定义:也叫最少知识原则(LKP,Least Knowledge Principle).如果两个类不必彼此直接通信,那么这两个类就不应当发生直接的相互作用.如果其中的一个类需要调用 ...
- 如何修改SESSION的生存时间
php中session过期时间设置网上很多人给出了解答:修改php配置文件中的session.gc_maxlifetime.如果想了解更多session回收机制,继续阅读.(本文环境php5.2) 概 ...
- [浪风推荐]CURL伪造IP和来源
给“刷票”的朋友提供了很好的换IP的方案,查了下,CURL确实很强悍的可以伪造IP和来源. 1.php 请求 2.php . 1.php代码: $ch = curl_init(); curl_seto ...
- 红外图像处理之直方图均衡的matlab源码与效果验证
红外图像是热辐射成像,由于场景中的目标与背景的温差相对较小,红外图像的动态范围大.对比度 低, 信噪比也较可见光图像的低.为了能够从红外图像中正确地识别出目标,必须对红外图像进行增强处理.一般红外探测 ...
- ios -生成推广海报
#import "ViewController.h" #import "Masonry.h" @interface ViewController () @end ...
- vue 流程
1.vue 项目搭建 2.监听 3.组件 4.路由
- [Spring Data MongoDB]学习笔记--MapReduce
mongodb的MapReduce主要包含两个方法:map和reduce. 举个例子,假设现在有下面3条记录 { "_id" : ObjectId("4e5ff893c0 ...
- rest规范 ; restful 风格; gradel介绍 ; idea安装 ;
[说明]上午整理了一下心情:下午继续开始任务,了解了restful,知道了那个牛人的博士论文,下载了管理工具gradle,并且部署了环境:晚上安装了idea继承环境并且建了一个简单的gradle项目( ...
- 《从零开始学Swift》学习笔记(Day 18)——有几个分支语句?
原创文章,欢迎转载.转载请注明:关东升的博客 分支语句又称条件语句,Swift编程语言提供了if.switch和guard三种分支语句. if语句 由if语句引导的选择结构有if结构.if ...