题目链接

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. 点赞狂魔 【水】的更多相关文章

  1. PAT 天梯赛 L1-047. 装睡 【水】

    题目链接 https://www.patest.cn/contests/gplt/L1-047 AC代码 #include <iostream> #include <cstdio&g ...

  2. PAT 天梯赛 L1-042. 日期格式化 【水】

    题目链接 https://www.patest.cn/contests/gplt/L1-042 AC代码 #include <iostream> #include <cstdio&g ...

  3. PAT 天梯赛 L1-041. 寻找250 【水】

    题目链接 https://www.patest.cn/contests/gplt/L1-041 AC代码 #include <iostream> #include <cstdio&g ...

  4. PAT 天梯赛 L1-022. 奇偶分家 【水】

    题目链接 https://www.patest.cn/contests/gplt/L1-022 AC代码 #include <iostream> #include <cstdio&g ...

  5. PAT 天梯赛 L1-016. 查验身份证 【水】

    题目链接 https://www.patest.cn/contests/gplt/L1-016 AC代码 #include <iostream> #include <cstdio&g ...

  6. PAT 天梯赛 L1-014. 简单题 【水】

    题目链接 https://www.patest.cn/contests/gplt/L1-014 AC代码 #include <iostream> #include <cstdio&g ...

  7. PAT 天梯赛 L1-012. 计算指数 【水】

    题目链接 https://www.patest.cn/contests/gplt/L1-012 AC代码 #include <iostream> #include <cstdio&g ...

  8. PAT 天梯赛 L1-010. 比较大小 【水】

    题目链接 https://www.patest.cn/contests/gplt/L1-010 AC代码 #include <iostream> #include <cstdio&g ...

  9. PAT 天梯赛 L1-007. 念数字 【水】

    题目链接 https://www.patest.cn/contests/gplt/L1-007 AC代码 #include <iostream> #include <cstdio&g ...

  10. PAT 天梯赛 L1-004. 计算摄氏温度 【水】

    题目链接 https://www.patest.cn/contests/gplt/L1-004 AC代码 #include <iostream> #include <cstdio&g ...

随机推荐

  1. iOS valueForKeyPath快速计算求和、平均值、最大、最小

    iOS中开始取出数组中最大值,最小值除了使用排序的方式,还可以使用valueForKeyPath的方式直接取出 array = @[@(10),@(100),@(20),@(97)]; CGFloat ...

  2. 获取UUID

    UDID 设备的唯一标识符,也就是设备的序列号,在iOS2.0版本中UIDevice提供了一个获取设备唯一标识符的方法uniqueldentifier,这个方法也是为一个可以确认获取此标识符的方法.但 ...

  3. iOS多线程(转)

    关于iOS多线程,你看我就够了 字数8596 阅读28558 评论74 喜欢313 在这篇文章中,我将为你整理一下 iOS 开发中几种多线程方案,以及其使用方法和注意事项.当然也会给出几种多线程的案例 ...

  4. Windows 7 SP1和Windows Server 2008 SP1的Event ID 10错误的解决方法

    安装了Windows 7 Service Pack 1 (SP1) 或 Windows Server 2008 R2 Service Pack 1 (SP1)都会遇到此错误提示. "Even ...

  5. Yii2的redis扩展

    在应用的时候需要先对yii2进行扩展安装 如果装有composer直接运行 php composer.phar require --prefer-dist yiisoft/yii2-redis 当然也 ...

  6. 阿里云Ubuntu环境搭建Docker服务

    经过昨天和今天的不断奋战,在阿里云里面搭建Docker并不easy. 所以我认为有必要记录下来,以供后人学习. 以及我自己的回想. 首先,查看我们的系统版本号: cat /etc/issue 的到的输 ...

  7. Eclipse调试部分手机不显示日志问题解决

    在拨号键盘输入一串指令,然后会进入到工程模式,最后可以在Log设置里面设置了. 华为:*#*#2846579#*#* 酷派:*20121220#

  8. VC编译那些事儿

    转载自:http://blog.csdn.net/wowolook/article/details/8077153     最近又被ms的编译选译纠结了一下,运行程序是老是弹出0x14b1 or 71 ...

  9. java解析xml字符串为实体(dom4j解析)

    package com.smsServer.Dhst; import java.util.HashMap; import java.util.Iterator; import java.util.Ma ...

  10. [Docker]学习笔记--搭建gitlab

    Gitlab 是一个用于仓库管理系统的开源项目.使用Git作为代码管理工具,并在此基础上搭建起来的web服务. 详细介绍可以参照官网,https://about.gitlab.com/ 今天主要是通过 ...