7-7 quietly attention (25 points)

Source: Internet
Author: User

Sina Weibo has a "quiet attention", a user quietly focus on the person, does not appear on the user's list of concerns, but the system will push its quietly concerned about the microblog published by the user. Now we're going to be a cyber detective, picking out people who are likely to be secretly concerned, based on a list of their concerns and their point of praise for other users. Input format:

Enter the list of concerns given to a user first in the first line, in the following format:

Number n users 1 users 2 ... User n

where n is a positive integer of no more than 5000, each user I (I=1, ..., N) is the ID of the user to whom it is concerned, a string of digits and English letters of length 4 digits, separated by a space.

Then give the user a point of praise: First give a positive integer m not more than 10000, followed by M row, each row gives a user ID of its point and the number of points of praise for the user (not more than 1000), separated by a space. Note: The user ID is the unique identity of a user. The topic ensures that there are no duplicate users in the attention list, and there is no duplicate user in the point-praise message. Output format:

We think people who have been praised by the user more than their point-praise averages, and are not on their list of concerns, are likely to be the people they secretly focus on. Based on this assumption, you can print the user ID alphabetically in ascending order by the person who may be secretly concerned, 1 IDs per line. If there is no such person, then output "Bing Mei you." Enter Sample 1:

Magi Zha1 Sen1 Quan famk lsum eins fatm llao 8 magi GAO3 Pota llao
3
ammy to
Dave
GAO3
Zoro 1
Cath 60
Output Sample 1:
Ammy
Cath
Pota
Enter Sample 2:
One GAO3 magi Zha1 Sen1 Quan famk lsum eins fatm llao Pota
7
magi Pota Llao m
ammy 3
Dave 15
GAO3
Zoro 29
Output Sample 2:
Bing Mei You
My Code:

#include <iostream>
#include <set>
#include <map>
#include <string>
using namespace std;
set<string>s;
map<string,int>p,pp;
int main ()
{
	int i,n,m,sum=0,t;
	String name,a[10001];
	cin>>n;
	while (n--)
	{
		cin>>name;
		p[name]=1;
	}
	cin>>m;
	for (i=0;i<m;i++)
	{
		cin>>a[i]>>t;
		pp[a[i]]=t;
		sum=sum+t;
	}
	sum=sum/m;
	for (i=0;i<m;i++)
	{
		if (p[a[i]]==0 && pp[a[i]]>sum)
			S.insert (a[i));
	if (S.empty ())
	{
		puts ("Bing Mei You");
		return 0;
	}
	Set<string>::iterator it;
	For (It=s.begin (); It!=s.end (); it++)
		cout<<*it<<endl;
	return 0;
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.