l2-019. Quietly focus on time limit MS
Memory Limit 65536 KB
Code length limit 8000 B
Standard author Chen Yue The procedure of the sentence
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, and is a 4-digit string of numbers and English letters, 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
D Ave
GAO3
Zoro 29
Output Sample 2:
Bing Mei You
Problem solving idea: This problem is very water, a map can be solved ...
The code is as follows:
#include <bits/stdc++.h>
using namespace std;
struct p{
int x;
Char y[20];
} A[10001];
BOOL CMP (P a,p b)
{
if (strcmp (A.Y,B.Y) >0) return false;
else return true;
}
int main ()
{
int n,m,f=0;
Char s[20];
map<string,int>m;
scanf ("%d", &n);
for (int i=0;i<n;i++)
{
scanf ("%s", s);
m[s]=1;
}
Double s1=0;
scanf ("%d", &m);
for (int i=0;i<m;i++)
{
scanf ("%s%d", &a[i].y,&a[i].x);
s1+=a[i].x;
}
s1/=m;
Sort (a,a+m,cmp);
for (int i=0;i<m;i++)
if (a[i].x>s1&&! M[A[I].Y])
{f=1; printf ("%s\n", A[i].y);}
if (!f) printf ("Bing Mei you\n");
return 0;
}