#include <bits/stdc++.h>
#define MAX 1000006
using namespace std;
struct hs
{
string ht;
int to,ti,stt;
};
hs a[MAX];
int n;
void nhap()
{
cin >> n;
string s;
getline(cin,s);
for(int i=1; i<=n; i++)
{
getline(cin,a[i].ht);
cin >> a[i].to >> a[i].ti;
a[i].stt=i;
getline(cin,s);
}
}
bool ss(hs &x, hs &y)
{
if((x.to+x.ti)>(y.to+y.ti)) return true;
if((x.to+x.ti)<(y.to+y.ti)) return false;
if(x.ti>y.ti) return true;
if(x.ti<y.ti) return false;
if(x.stt<y.stt) return true;
if(x.stt>y.stt) return false;
return true;
}
void giai ()
{
sort(a+1,a+1+n,ss);
cout<<a[1].stt<<endl; cout<<a[1].ht<<endl;
cout<<a[2].stt<<endl; cout<<a[2].ht<<endl;
cout<<a[3].stt<<endl; cout<<a[3].ht<<endl;
}
int main ()
{
ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
freopen("CHON.inp","r",stdin);
freopen("CHON.out","w",stdout);
nhap();
giai();
}
* Chuyên dạy lập trình ONLINE cho học sinh THCS, THPT *.
Mọi giao lưu, trao đổi, xin liên hệ: Lê Quang Vinh - zalo: 037.803.8755.
Page: Lớp học Code Sky
Group FB1: Ôn thi HSG9 - THTB - TS10 chuyên tin
Group FB2: Học Scratch - Ôn thi Tin học trẻ bảng A
Thứ Năm, 16 tháng 6, 2022
chon c++ (sort)
Đăng ký:
Đăng Nhận xét (Atom)
Không có nhận xét nào:
Đăng nhận xét
Lưu ý: Chỉ thành viên của blog này mới được đăng nhận xét.