#include <iostream>
#include <vector>
#include <algorithm>
#include <stdio.h>
using namespace std;
struct student
{
public:
int id;
int des;
int cais;
int zong;
};
bool comp(student a, student b)
{
if (a.zong>b.zong)
{
return true;
}
else if (a.zong==b.zong)
{
if (a.des>b.des)
{
return true;
}
else if (a.des==b.des)
{
if (a.id<b.id)
{
return true;
}
}
}
return false;
}
int _tmain(int argc, _TCHAR* argv[])
{
int n;
cin >> n;
int low, high;
cin >> low >> high;
int id_temp,de_temp,cai_temp;
vector<student> s1, s2, s3, s4;
student temp;
int cnt = 0;
for (int i = 0; i < n;++i)
{
cin >> id_temp >> de_temp >> cai_temp;
temp.id = id_temp;
temp.des = de_temp;
temp.cais = cai_temp;
temp.zong = de_temp + cai_temp;
if (de_temp>=low&&cai_temp>=low)
{
++cnt;
if (de_temp >= high&&cai_temp >= high)
{
s1.push_back(temp);
}
else if (de_temp>=high&&cai_temp<high)
{
s2.push_back(temp);
}
else if (de_temp < high&&cai_temp < high&&de_temp >= cai_temp)
{
s3.push_back(temp);
}
else
s4.push_back(temp);
}
}
cout << cnt << endl;
sort(s1.begin(), s1.end(), comp);
sort(s2.begin(), s2.end(), comp);
sort(s3.begin(), s3.end(), comp);
sort(s4.begin(), s4.end(), comp);
for (auto c:s1)
{
printf("%d %d %d\n", c.id, c.des, c.cais); //使用cout輸出會超時
}
for (auto c : s2)
{
printf("%d %d %d\n", c.id, c.des, c.cais);
}
for (auto c : s3)
{
printf("%d %d %d\n", c.id, c.des, c.cais);
}
for (auto c : s4)
{
printf("%d %d %d\n", c.id, c.des, c.cais);
}
return 0;
}
1015.德才論
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.