본문 바로가기

알고리즘 · 코딩

[SWEA 1983] 조교의 성적 매기기

문제 링크

https://swexpertacademy.com/main/code/problem/problemDetail.do?problemLevel=2&contestProbId=AV5PwGK6AcIDFAUq&categoryId=AV5PwGK6AcIDFAUq&categoryType=CODE&problemTitle=&orderBy=FIRST_REG_DATETIME&selectCodeLang=CCPP&select-1=2&pageSize=10&pageIndex=1 

 

SW Expert Academy

SW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요!

swexpertacademy.com


C++ 풀이

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

int main() {
	int T, N, K;
	cin >> T;
	for (int i = 1; i <= T; ++i) {
		vector <pair <int, int> > score; // <총점, 학생 번호>
		cin >> N >> K;
		for (int j = 1; j <= N; ++j) {
			int mid, fin, work;
			cin >> mid >> fin >> work;
			score.push_back({ ((mid * 35) + (fin * 45) + (work * 20)), j });
		}
		sort(score.begin(), score.end());
		for (int j = 1; j <= N; ++j) {
			if (score[j].second == K) {
				int rate = (double)j / N * 100;

				if (rate < 10)
					cout << "#" << i << " " << "D0" << endl;
				else if (rate < 20)
					cout << "#" << i << " " << "C-" << endl;
				else if (rate < 30)
					cout << "#" << i << " " << "C0" << endl;
				else if (rate < 40)
					cout << "#" << i << " " << "C+" << endl;
				else if (rate < 50)
					cout << "#" << i << " " << "B-" << endl;
				else if (rate < 60)
					cout << "#" << i << " " << "B0" << endl;
				else if (rate < 70)
					cout << "#" << i << " " << "B+" << endl;
				else if (rate < 80)
					cout << "#" << i << " " << "A-" << endl;
				else if (rate < 90)
					cout << "#" << i << " " << "A0" << endl;
				else
					cout << "#" << i << " " << "A+" << endl;

				break;
			}
		}
	}
	return 0;
}

각 항목(중간, 기말, 과제)에 대해 가중치를 곱해서 총점을 구한 후, 각 학생들의 총점을 정렬하여 찾는 학생의 비율에 맞는 평점을 구했다.

 

 

LIST