์ฝ๋
#include <string>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;
struct addScore{
vector<int>score; //ํ๊ท ์ ์ ๊ณ์ฐํ๋ ์ ์(์ด)
};
char check(double avg){
if(avg>=90) return 'A';
else if(avg>=80&&avg<90) return 'B';
else if(avg>=70&&avg<80) return 'C';
else if(avg>=50&&avg<70) return 'D';
else if(avg<50) return 'F';
return 0;
}
string solution(vector<vector<int>> scores) {
string answer = "";
vector<addScore>addScore;
map<int,int>m[500];
for(int i=0; i<scores.size(); i++){
vector<int>temp;
for(int k=0; k<scores.size(); k++){
temp.push_back(scores[k][i]); //์ธ๋ก๋ก ๋ฃ์ด์ค(์ด).
m[i][scores[k][i]]++; //์ค๋ณต๋ ์ ์ ์ฒดํฌ
}
addScore.push_back({temp});
}
for(int i=0; i<scores.size(); i++){
double sum=0;
int cnt=0;
int max_value=*max_element(addScore[i].score.begin(), addScore[i].score.end()); //ํ ํ์์ด ๋ฐ์ ์ต๊ณ ์ ์ ์ฐพ๊ธฐ
int min_value=*min_element(addScore[i].score.begin(), addScore[i].score.end()); //ํ ํ์์ด ๋ฐ์ ์ต์ ์ ์ ์ฐพ๊ธฐ
for(int k=0; k<scores.size(); k++){
if(i==k){
if(scores[k][i]==max_value){ //๋ณธ์ธ์๊ฒ ์ต๊ณ ์ ์๋ฅผ ๋งค๊ฒจ์คฌ์๋
if(m[i][scores[k][i]]!=1){
sum+=scores[k][i]; //์ค๋ณต๋ ์ ์๊ฐ ์๋ค๋ฉด ํ๊ท ๋ด์ค
cnt++;
}
}
else if(scores[k][i]==min_value){ //๋ณธ์ธ์๊ฒ ์ต์ ์ ์๋ฅผ ๋งค๊ฒจ์คฌ์๋
if(m[i][scores[k][i]]!=1){
sum+=scores[k][i]; //์ค๋ณต๋ ์ ์๊ฐ ์๋ค๋ฉด ํ๊ท ๋ด์ค
cnt++;
}
}
else{
sum+=scores[k][i];
cnt++;
}
}
else{
sum+=scores[k][i];
cnt++;
}
}
sum/=cnt;
answer+=check(sum);
}
return answer;
}
๋๊ธ