PAT天梯赛 L2-019. 悄悄关注 【STL】
2024-09-03 20:06:22
题目链接
https://www.patest.cn/contests/gplt/L2-019
思路
将已关注的人 用 MAP存起来
然后将点赞的用户中 没有关注的 用 VECTOR 存下来 并且求出 SUM
再遍历那个 VECTOR 用另一个VECTOR 存下 点赞数 大于平均数 的人
最后 排序 输出
AC代码
#include <cstdio>
#include <cstring>
#include <ctype.h>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <deque>
#include <vector>
#include <queue>
#include <string>
#include <map>
#include <stack>
#include <set>
#include <numeric>
#include <sstream>
#include <iomanip>
#include <limits>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <string, int> psi;
const double PI = 3.14159265358979323846264338327;
const double E = exp(1);
const double eps = 1e-6;
const int INF = 0x3f3f3f3f;
const int maxn = 1e5 + 5;
const int MOD = 1e9 + 7;
int main()
{
map <string, int> m;
int n;
scanf("%d", &n);
string s;
for (int i = 0; i < n; i++)
{
cin >> s;
m[s] = 1;
}
scanf("%d", &n);
double sum = 0.0;
int num;
vector <psi> v;
vector <string> ans;
for (int i = 0; i < n; i++)
{
cin >> s;
scanf("%d", &num);
sum += num;
if (m[s] == 0)
v.push_back(psi(s, num));
}
sum = sum * 1.0 / n;
vector <psi>::iterator it;
for (it = v.begin(); it != v.end(); it++)
{
if ((*it).second > sum)
ans.push_back((*it).first);
}
if (ans.size())
{
sort(ans.begin(), ans.end());
vector <string>::iterator iter;
for (iter = ans.begin(); iter != ans.end(); iter++)
cout << (*iter) << endl;
}
else
printf("Bing Mei You");
}
最新文章
- 0038 Java学习笔记-多线程-传统线程间通信、Condition、阻塞队列、《疯狂Java讲义 第三版》进程间通信示例代码存在的一个问题
- flask笔记1-安装
- android Sqlite select * from myDatabase没有内容的问题
- Raspberry PI B+ debian + wifi 网络设置
- 微信、qq信息汇总、回复(一)
- poj 2709
- 深入理解JAVA I/O系列六:Linux中的IO模型
- Linux重置mysql密码(转载)
- PAT1075. PAT Judge
- 【JavaScript】HTML5/CSS3实现五彩进度条应用
- CH Round #52 - Thinking Bear #1 (NOIP模拟赛)
- javascript 学习随笔
- Jquery中日期插件jquery.datepick的使用
- 第一天上午——HTML网页基础知识以及相关内容
- 码农很忙代理IP系统V1.0版本上线
- CSS 静态进度条效果
- 洛谷P2278操作系统
- Not supported for DML operations
- uniGUI试用笔记(十一)
- python爬虫之一:requests库