ACM Class Average 2



Problem Link: http://acm.epoka.edu.al:8888/en/problem-pid-c7c0?ps=1&smt=9&smpwid=0



#include <bits/stdc++.h>
#include <algorithm>
using namespace std;

bool comparegrade(const pair<string,double>& x, const pair<string, double>& y )
{
    return (x.second < y.second); //ascending
}

int main()
{
    string f,l,fn;
    double a,b,c,d,e,av,ca,sum=0.00,cnt=0,point;
    int n,i,j;
    vector<pair<string,double> >s;
    vector<string>ln;
   // freopen("input.txt","rt",stdin);
    //freopen("output.txt","w",stdout);
    cin>>n;
    for(i=1;i<=n;i++)
    {
        cin>>f>>l>>a>>b>>c>>d>>e;
        fn=f+" "+l;
        av=(a*15)/100.00+(b*15)/100.00+(c*20)/100.00+(d*25)/100.00+(e*25)/100.00;
        sum=sum+av;
        s.push_back(make_pair(fn,av));
    }
    ca=sum/n;
    sort(s.begin(),s.end(),comparegrade);
    vector<pair<string,double> >::iterator p;

    for(p=s.begin();p!=s.end();p++)
    {

          if(p->second>=ca)
          {
              point=p->second;
              cout<<p->first<<" ";
              printf("%0.2f\n",point);
          }


    }

    return 0;
}

Download Coding Interview Book and Get More Tutorials for Coding and Interview Solution: Click Here

Download System Design Interview Book and Get More Tutorials and Interview Solution: Click Here

Do you need more Guidance or Help? Then Book 1:1 Quick Call with Me: Click Here

Share on Google Plus

About Ashadullah Shawon

I am Ashadullah Shawon. I am a Software Engineer. I studied Computer Science and Engineering (CSE) at RUET. I Like To Share Knowledge. Learn More: Click Here
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment