L2-019 Suivre tranquillement (25 points)
une analyse:
La fonction de réglage et la fonction de carte accélèrent la recherche.
Code:
#include <bits/stdc++.h>
using namespace std;
int main()
{
map <string, int> m;
set <string> s;
pair <string, int> peo[10010];
int n;
double ave = 0;
cin >> n;
while (n--)
{
string temp;
cin >> temp;
m[temp] = 1;
}
cin >> n;
for (int i = 0; i<n; i++)
{
cin >> peo[i].first >> peo[i].second;
ave += peo[i].second;
}
ave /= n;
for (int i = 0; i<n; i++)
{
if (m[peo[i].first] == 0 && peo[i].second>ave)s.insert(peo[i].first);
}
set<string>::iterator it;
for (it = s.begin(); it != s.end(); it++)
{
cout << *it << endl;
}
if (s.empty())cout << "Bing Mei You";
return 0;
}