Submission #197998

# Submission time Handle Problem Language Result Execution time Memory
197998 2020-01-24T12:58:25 Z model_code ACM (COCI19_acm) C++17
50 / 50
14 ms 428 KB
#include <string>
#include <iostream>
using namespace std;

const int maxm = 20;
const int maxn = 1005;

int n, m;
string name[maxn];
int penalty[maxn];

int teamIndex;
int solved[maxn];
int endList[maxn];

int getNumber(string &task) {
	int ret = 0;
	while (task[0] != '/') {
		ret = ret * 10 + (task[0] - '0');
		task = task.substr(1);
	}
	task = task.substr(1);
	return ret;
}

int dig(char x) {
	return x - '0';
}

int parseTime(string taskTime) {
	return dig(taskTime[1]) * 60 * 60 + dig(taskTime[3]) * 10 * 60 + dig(taskTime[4]) * 60 + dig(taskTime[6]) * 10 + dig(taskTime[7]);
}

void load(int index) {
	solved[index] = 0;
	penalty[index] = 0;
	for (int i = 0; i < m; i++) {
		string task;	
		cin >> task;
		if (task[0] != '-') {
			solved[index]++;
			task = task.substr(1);
			int submissions = getNumber(task);
			penalty[index] += submissions * 20 * 60 + parseTime(task);			
		}
	}	
}

bool cmp(int x, int y) {
	if (solved[x] != solved[y])
		return solved[x] > solved[y];
	if (penalty[x] != penalty[y])
		return penalty[x] < penalty[y];
	return name[x] < name[y];
}

int main (void) {
	cin >> n >> m;
	for (int i = 0; i < n; i++) {
		cin >> name[i];
		if (name[i] == "NijeZivotJedanACM") 
			teamIndex = i;
		load(i);
	}	
	cin >> name[teamIndex];
	load(teamIndex);
	int sol = 1;
	for (int i = 0; i < n; i++)
		if (i != teamIndex) 
			sol += (int)cmp(i, teamIndex);
	cout << sol << endl;
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 13 ms 428 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 14 ms 376 KB Output is correct
5 Correct 14 ms 380 KB Output is correct