0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-12-12 20:26:27 +00:00
OI-codes/Luogu/P5741/P5741.cpp

63 lines
1.3 KiB
C++
Raw Normal View History

// R38779683
#include <bits/stdc++.h>
using namespace std;
struct node {
string name;
2021-11-19 09:01:13 +00:00
int chinese;
int math;
int english;
int all;
node() {
2021-11-19 09:01:13 +00:00
this->name = "";
this->chinese = this->math = this->english = this->all = 0;
}
void read() {
cin >> this->name >> this->chinese >> this->math >> this->english;
this->all = this->chinese + this->math + this->english;
}
};
bool cmp(node a, node b) {
return a.all > b.all;
}
bool query(node a, node b) {
2021-11-19 09:01:13 +00:00
if (abs(a.chinese - b.chinese) <= 5) {
if (abs(a.math - b.math) <= 5) {
if (abs(a.english - b.english) <= 5) {
if (abs(a.all - b.all) <= 10) {
return true;
}
}
}
}
return false;
}
int main() {
2021-11-19 09:01:13 +00:00
int n;
node a[1005];
cin >> n;
for (int i = 0; i < n; i++) {
a[i].read();
}
// sort(a, a + n, cmp);
2021-11-19 09:01:13 +00:00
for (int i = 0; i < n; i++) {
for (int j = i + 1; j < n; j++) {
if (query(a[i], a[j])) {
if (a[i].name < a[j].name) {
cout << a[i].name << ' ' << a[j].name << endl;
2021-11-19 09:01:13 +00:00
} else {
cout << a[j].name << ' ' << a[i].name << endl;
}
}
}
}
return 0;
}