Skip to content

Latest commit

 

History

History
102 lines (92 loc) · 1.88 KB

1141.md

File metadata and controls

102 lines (92 loc) · 1.88 KB

1141

image.png

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

int N;
const int MAX_N = 1e5 + 5;
struct School {
	string name = "";
	int scoreB = 0, scoreA = 0, scoreT = 0;
	int num = 0;
	int score = 0;
	int rank = 0;
} ss[MAX_N];
map<string, int> m;

bool cmp(School s1, School s2) {
	if (s1.score == s2.score) {
		if (s1.num == s2.num) {
			return s1.name < s2.name;
		}
		return s1.num < s2.num;
	}
	return s1.score > s2.score;
}

int main() {
	cin >> N;
	int num = 0;
	for (int n = 0; n < N; n++) {
		string id, school;
		int score;
		cin >> id >> score >> school;
		transform(school.begin(), school.end(), school.begin(), ::tolower);
		if (m.count(school) == 0) {
			m[school] = num++;
			ss[m[school]].name = school;
		}
		if (id[0] == 'B') {
			ss[m[school]].scoreB += score;
		}
		else if (id[0] == 'A') {
			ss[m[school]].scoreA += score;
		}
		else {
			ss[m[school]].scoreT += score;
		}
		ss[m[school]].num++;
	}
	for (int i = 0; i < num; i++) {
		ss[i].score = (int)((double)ss[i].scoreB / 1.5 + (double)ss[i].scoreA + (double)ss[i].scoreT * 1.5);
	}
	cout << num << endl;
	sort(ss, ss + num, cmp);
	int r = 1, cnt = 1;
	cout << "1 " << ss[0].name << " " << ss[0].score << " " << ss[0].num << endl;
	for (int i = 1; i < num; i++) {
		if (ss[i].score == ss[i - 1].score) {
			cnt++;
		}
		else {
			r += cnt;
			cnt = 1;
		}
		cout << r << " " << ss[i].name << " " << ss[i].score << " " << ss[i].num << endl;
	}
	return 0;
}

/*
Sample Input:
10
A57908 85 Au
B57908 54 LanX
A37487 60 au
T28374 67 CMU
T32486 24 hypu
A66734 92 cmu
B76378 71 AU
A47780 45 lanx
A72809 100 pku
A03274 45 hypu
Sample Output:
5
1 cmu 192 2
1 au 192 3
3 pku 100 1
4 hypu 81 2
4 lanx 81 2
*/

References