#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(int argc, char** argv)
{
int N;
cin >> N;
vector<int> grade[3];
vector<int> result[3];
bool check;
vector<int> cur;
vector<int> total(N,0);
vector<int> final(N,0);
int num;
for(int i=0; i<3; i++){
for(int j=0; j<N; j++){
int g;
cin >> g;
grade[i].push_back(g);
result[i].push_back(0);
}
}
for(int i=0; i<3; i++){
num=1;
check=false;
cur = grade[i];
//copy(grade[i].begin(), grade[i].end(), back_inserter(cur));
while(check!=true){
int max = *max_element(cur.begin(), cur.end());; // value of max
int count=0; // 동점 카운팅
for(int j=0; j<N; j++){
if(cur[j] == max) {
result[i][j] = num;
cur[j] = -1;
count++;
}
}
//cout << endl;
num=num+count; // 다음 등수 = “나보다 점수가 큰 사람”의 수 + 1
check = all_of(cur.begin(), cur.end(), [](int k) { return k == -1; }); // 현재 대회에서 참가자의 점수 모두 체크했는지 확인
}
}
// 대회별 참가자 성적에 대한 등수 출력
for(int i=0; i<3; i++){
for(int j=0; j<N; j++) cout << result[i][j] << " ";
cout << endl;
}
// 각 참가자의 점수합 구하기
for(int i=0; i<N; i++){
for(int j=0; j<3; j++){
total[i] += grade[j][i];
}
}
// 각 참가자의 등수 구하기
num=1;
check=false;
while(check!=true) {
int count=0;
int max = *max_element(total.begin(), total.end());
for(int i=0; i<N; i++){
if(total[i] == max) {
final[i] = num;
count++;
total[i] = -1;
}
}
num=num+count; // 다음 등수 = “나보다 점수가 큰 사람”의 수 + 1
check = all_of(total.begin(), total.end(), [](int i){ return i == -1; });
}
// 최종 등수 출력
for(int n : final) cout << n << " ";
return 0;
}
[프로그래머스] 게임 맵 최단거리 (C++) (0) | 2023.09.08 |
---|---|
[Softeer] 8단 변속기 (C++) (0) | 2023.09.06 |
[Softeer] 장애물 인식 프로그램 (C++) (0) | 2023.08.12 |
[Softeer] GBC (C++) (0) | 2023.08.12 |
[BOJ] 1389: 케빈 베이컨의 6단계 법칙 (C++) (0) | 2023.07.29 |