반응형
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;
}
반응형
'백준 문제풀이' 카테고리의 다른 글
백준 1181번 - 단어 정렬 소스 코드 (0) | 2021.04.18 |
---|---|
백준 1546번 - 평균 소스 코드 (0) | 2021.04.18 |
백준 2504번 - 괄호의 값 (0) | 2021.04.16 |
백준 2568번 2565번 - 전깃줄 (0) | 2021.04.16 |
백준 2503번 - 숫자 야구 (0) | 2021.04.15 |