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;
}
0 comments:
Post a Comment