AcWing 3604. 最小年龄的3个职工
原题链接
简单
#include<bits/stdc++.h>
using namespace std;
struct nd{
int id;
string name;
int age;
bool operator<(const nd& nd1)const{
if(age==nd1.age){
if(id==nd1.id){
return name<nd1.name;
}
return id<nd1.id;
}
return age<nd1.age;
}
};
const int N = 30+5;
nd nnd[N];
int main(){
int n;
cin>>n;
for(int i = 1;i<=n;i++){
cin>>nnd[i].id>>nnd[i].name>>nnd[i].age;
}
sort(nnd+1,nnd+1+n);
for(int i = 1;i<=min(n,3);i++){
cout<<nnd[i].id<<" "<<nnd[i].name<<" "<<nnd[i].age<<"\n";
}
return 0;
}