L2-019 悄悄关注
题目 L2-019 悄悄关注
思路分析
代码实现
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
using ll = long long;
using ull = unsigned long long;
using PII = pair<int,int>;
using Pll = pair<ll,ll>;
int dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
const int inf = 0x3f3f3f3f;
using PSD = pair<string,double>;
set<string> attentionList;
priority_queue<PSD> possible;
int main(){
ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
int n,m;
cin>>n;
while(n--){
string s;cin>>s;
attentionList.insert(s);
}
cin>>m;
double sum=0,aver=0;
for(int i=0;i<m;i++){
string name;double like;
cin>>name>>like;
if(attentionList.find(name)==attentionList.end()){
possible.push({name,like});
}
sum+=like;
}
aver=sum/m;
// cout<<"aver: "<<aver<<endl;
bool havefind=false;
vector<string> ans;
while(!possible.empty()){
auto people = possible.top(); possible.pop();
if(people.second>aver){
// cout<<people.first<<" dianzan: "<<people.second<<endl;
havefind=true;
ans.push_back(people.first);
}
}
if(!havefind){
cout<<"Bing Mei You";
}else{
for(int i=ans.size()-1;i>=0;i--)
cout<<ans[i]<<endl;
}
return 0;
}
同类题型
视频讲解
⬅️ L2-018 多项式A除以B 🏠 00-天梯赛 ➡️ L2-020 功夫传人
💬 评论