0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-11-10 02:18:48 +00:00

P5741 【深基7.例10】旗鼓相当的对手 - 加强版

R38779683
This commit is contained in:
Baoshuo Ren 2020-09-23 18:52:51 +08:00 committed by Baoshuo Ren
parent 1d766c6c20
commit ac0248d390
Signed by: baoshuo
GPG Key ID: 70F90A673FB1AB68

63
problem/P5741/P5741.cpp Normal file
View File

@ -0,0 +1,63 @@
// R38779683
#include <bits/stdc++.h>
using namespace std;
struct node {
string name;
int chinese;
int math;
int english;
int all;
node() {
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) {
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() {
int n;
node a[1005];
cin >> n;
for (int i = 0; i < n; i++) {
a[i].read();
}
// sort(a, a + n, cmp);
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;
}
else {
cout << a[j].name << ' ' << a[i].name << endl;
}
}
}
}
return 0;
}