Portal: https://www.patest.cn/contests/gplt/L2-019 #include <queue> #include <functional> #include < stdio.h> #include <string.h> #include <iostream> #include <algorithm> #include <stack> # Include <vector> #include <set> #include <map> #include <string> #include <cmath> #include
<cstdlib> #include <ctime> #include <assert.h> using namespace std;
* *: Record the list of praised list, count all the points and average, traverse the list of praise, if the person's point of praise is greater than the average and not in the attention list, then use set to record the name.
The dictionary order is automatically implemented with set.
* * #define N 100005 #define M struct Node {string s;
int num; }NO[10005]; Record list map<string,int>mp; Record the attention of the people set<string>se;
Log answer int main () {int n;
string S;
scanf ("%d", &n);
for (int i=0;i<n;i++) {cin>>s;
mp[s]++;
} scanf ("%d", &n);
int sum = 0;
for (int i=0;i<n;i++) {cin>>no[i].s;
cin>>no[i].num;
sum + + no[i].num; } Double avg = sum * 1. N Calculates the average for (int i=0;i<n;i++) {if (Mp[no[i].s]) continue; If you skip the IF (NO[I].NUM<AVG) continue;//in the attention list, skip Se.insert (NO[I].S) if less than the average; Meet the required answer, insert set in} if (Se.size () ==0) printf ("Bing Mei You"); No person who meets the requirements else{set<string>::iterator it;
Outputs the data for the record in set for (It=se.begin (); It!=se.end (); it++) {cout<<*it<<endl;
} return 0;
}