Submission #209329

# Submission time Handle Problem Language Result Execution time Memory
209329 2020-03-13T20:08:36 Z papa ACM (COCI19_acm) C++14
50 / 50
16 ms 632 KB
#include <string>
#include <iostream>
using namespace std;

//ideja je simulacija

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 5 ms 376 KB Output is correct
2 Correct 14 ms 504 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 16 ms 632 KB Output is correct
5 Correct 15 ms 504 KB Output is correct