20
#include <iostream>
#include <cstring>
#include <iomanip>
using namespace std;
struct Pacient {
char fullName[100];
bool insurance;
int checkups;
};
struct MaticenDoktor {
char name[100];
int patients;
Pacient p[200];
float price;
};
float suma(MaticenDoktor &m) {
float sum = 0;
for (int i = 0; i<m.patients; i++) {
if (!m.p[i].insurance)
sum+=m.p[i].checkups*m.price;
}
return sum;
}
float pregledi(MaticenDoktor &m) {
int n = 0;
for (int i = 0; i<m.patients; i++) n+=m.p[i].checkups;
return n;
}
void najuspesen_doktor(MaticenDoktor *m, int n) {
float maxBread = 0;
MaticenDoktor goat;
for (int i = 0; i<n; i++) {
if (suma(m[i])>maxBread) {
maxBread = suma(m[i]);
goat = m[i];
}
else if (suma(m[i])==maxBread) {
if (pregledi(goat)<pregledi(m[i])) {
goat = m[i];
}
}
}
cout<<goat.name<<" "<<fixed<<setprecision(2)<<suma(goat)<<" ";
cout<<fixed<<setprecision(0)<<pregledi(goat)<<endl;
}
int main() {
int n;
cin>>n;
MaticenDoktor doktori[n];
for (int i = 0; i<n; i++) {
cin>>doktori[i].name;
cin>>doktori[i].patients;
cin>>doktori[i].price;
for (int j = 0; j < doktori[i].patients; j++) {
cin>>doktori[i].p[j].fullName>>doktori[i].p[j].insurance>>doktori[i].p[j].checkups;
}
}
najuspesen_doktor(doktori,n);
}Editor is loading...
Leave a Comment