题目链接

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. 最新 AFNetworking 3.0 简单实用封装

    AFNetworking 3.0 的到来使我们开发者又方便了许多,话不多说,直接上代码. 1.首先 引入框架AFNetworking框架 GitHub下载地址:https://github.com/A ...

  2. objc_setAssociatedObject 使用(转)

    2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 ...

  3. 【转】SQL SERVER 2005 数据库状态为“可疑”的解决方法

    --MyDB为修复的数据名 USE MASTER GO SP_CONFIGURE 'ALLOW UPDATES',1 RECONFIGURE WITH OVERRIDE GO ALTER DATABA ...

  4. EOJ Problem #3249 状态压缩+循环周期+反向递推

    限量供应 Time limit per test: 4.0 seconds Time limit all tests: 4.0 seconds Memory limit: 256 megabytes ...

  5. spark单机模式

    1.下载spark,解压2.复制conf/spark-env.sh和conf/log4j.properties cp spark-env.sh.template spark-env.sh cp log ...

  6. 配置LANMP环境(5)-- 安装NGINX与配置

    安装nginx yum install nginx 若提示找不到nginx,则在软件源中添加nginx的软件源文件: vim /etc/yum.repos.d/nginx.repo 添加如下内容: [ ...

  7. 个人博客开发之 全局配置文件settings设置

    项目源码下载:http://download.vhosts.cn # -*- coding: utf-8 -*- """ Django settings for cpyb ...

  8. java 调用cmd命令

    public class Port{ public static void main(String[] args) { Runtime runtime=Runtime.getRuntime(); tr ...

  9. 如何给Eclipse添加一个JDK或JRE

    第一:  第二:  第三:  第四: 

  10. Error:“const char*”类型的实参与“wchar_t”类型的形参不兼容

    MainApp\RPolarView.cpp(1571): error C2664: “ATL::CStringT<BaseType,StringTraits>::ReverseFind” ...