pat-Practice set-l2-019. Quietly watching

Source: Internet
Author: User
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&LT;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;
 }

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.