반응형

www.acmicpc.net/problem/10825

 

10825번: 국영수

첫째 줄에 도현이네 반의 학생의 수 N (1 ≤ N ≤ 100,000)이 주어진다. 둘째 줄부터 한 줄에 하나씩 각 학생의 이름, 국어, 영어, 수학 점수가 공백으로 구분해 주어진다. 점수는 1보다 크거나 같고, 1

www.acmicpc.net

 

[ 백준 10825번 국영수 소스 코드 ]

#include <iostream>
#include <fstream>
#include <algorithm>
#include <vector>
using namespace std;

typedef pair<string, int> ai;
typedef pair<int, int> bi;
typedef pair<ai, bi> ci;

// first.second  국어
// second.first 영어 
// second.second  수학  

bool compare(ci x, ci y)
{
	if(x.first.second != y.first.second) 
		return x.first.second > y.first.second;
	else if(x.first.second == y.first.second && x.second.first == y.second.first && x.second.second == y.second.second )
		return x.first.first < y.first.first;
	else if(x.first.second == y.first.second && x.second.first == y.second.first ) 
		return x.second.second > y.second.second;
	else if(x.first.second == y.first.second) 
		return x.second.first < y.second.first;
    else
		return x.first.second > y.first.second;
}
int main()
{
	string s;
	int i,a,b,c,n;
	cin >> n;
	vector<ci> st;
	for(i=0;i<n;i++)
	{
		cin >> s >> a >> b >> c;
		st.push_back(ci(ai(s, a), bi(b, c)));
	}

	sort(st.begin(), st.end(),compare);
	
	for(i=0;i<st.size();i++)
	{
		cout << st[i].first.first << '\n';
	}
	
	return 0;
}
반응형
Posted by 명문코딩컴퓨터
,