求助大佬:全WA(样例对了
查看原帖
求助大佬:全WA(样例对了
465817
zhengziao楼主2022/9/19 21:28
#include <bits/stdc++.h>
using namespace std;

struct student
{
	string name;
	int ch, ma, en;
	//ch:chinese score, ma:math score, en:english score

};//struct student

//judge if it's a well-matched adversary
bool isValid(student x, student y)
{
	int sumx, sumy;
	
	sumx = x.ch + x.ma + x.en;
	sumy = y.ch + y.ma + y.en;
	
	if (abs(x.ch - y.ch) <= 5 && abs(x.ma - y.ma <= 5)
		&& abs(x.en - y.en) <= 5 && abs(sumx - sumy) <= 10)
	{
		return true;
	}
	
	return false;
	
}//bool isValid(student x, student y)

int main()
{
	int n;     //number of stuents;
	cin >> n;
	
	vector<student> stus(n);     //students
	for (int i = 0; i < n; i++)
		cin >> stus[i].name >> stus[i].ch >> stus[i].ma >> stus[i].en;
	
	for (int i = 0; i < n-1; ++i)
	{
		for (int j = i+1; j < n; ++j)
		{
			if (isValid(stus[i], stus[j]))
			{
				cout << stus[i].name << ' ' << stus[j].name << endl;
				return 0;
			}
		}
	}
	
	return 0;
	
}//int main()
2022/9/19 21:28
加载中...