네이버 코트는 나오는 방법을 찾다가 찾은 블로그 글입니다.
왠지 지금은 Programmers에서 문제가 풀린 것 같긴 한데, 난이도가 낮은 것 같아서 그냥 한 번 풀었습니다.
(프로그래머/자바)상호평가 – 네이버 코딩테스트(코트) 과거문제
https://programmers.co.kr/learn/courses/30/lessons/83201 코딩 시험 연습 – 2주 차 ((100,90,98,88,65),(50,45,99,85,77), (47,88,95,80,67),(61,57,100,80,65),(24,90,94,75,65)) “FBABD” ((70,49,90),(68,50 ,38),(73,31,100)) “CFD” Programmers.co.kr
drcode-devblog.tistory.com
내 솔루션
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
using namespace std;
int scores(11)(11);
string solution(int t){
string answer = "";
for (int i = 0; i < t; ++i){ // 최고점, 죄저점 처리
int maxs = *max_element(scores(i), scores(i) + t);
int mins = *min_element(scores(i), scores(i) + t);
if(scores(i)(i) == maxs) scores(i)(i)=-1;
else if(scores(i)(i) == mins) scores(i)(i)=-1;
}
for (int i = 0; i < t; ++i){
int sum = 0;
int cnt = 0;
for (int j = 0; j < t; ++j){
if(scores(j)(i)<0) continue;
sum += scores(j)(i);
cnt++;
}
sum /= cnt;
if(sum>=90) answer+="A";
else if(sum>=80) answer+="B";
else if(sum>=70) answer+="C";
else if(sum>=50) answer+="D";
else answer+="F";
}
return answer;
}
int main() {
ios_base::sync_with_stdio(false); cin.tie(NULL);
int t;
cin >> t;
for (int i = 0; i < t; ++i){
for (int j = 0; j < t; ++j){
cin >> scores(i)(j);
}
}
cout << solution
return 0;
}