Submission #207309

# Submission time Handle Problem Language Result Execution time Memory
207309 2020-03-07T06:51:57 Z socho ACM (COCI19_acm) C++14
50 / 50
16 ms 760 KB
#include "bits/stdc++.h"
using namespace std;


bool comp(pair<int, pair<int, string> > a, pair<int, pair<int, string> > b) {
	if (a.first > b.first) return true;
	if (a.first < b.first) return false;
	if (a.second.first < b.second.first) return true;
	if (a.second.first > b.second.first) return false;
	return a.second.second < b.second.second;
}

string us = "NijeZivotJedanACM";
int wrong_penalty = 20 * 60;

int main() {
	
	int n, t;
	cin >> n >> t;
	vector<pair<int, pair<int, string> > > scores;
	for (int i=0; i<n; i++) {
		string teamname;
		cin >> teamname;
		string results[t];
		for (int i=0; i<t; i++) {
			cin >> results[i];
		}
		if (teamname == us) continue;
		
		int solved = 0;
		int penalty = 0;
		for (int i=0; i<t; i++) {
			string curr = results[i];
			if (curr[0] == '-') {
				// can't have solved
			}
			else {
				// has solved if ? or +
				int attempts = (curr[1] - '0');
				int wrong_attempts = attempts - 1;
				solved++;
				penalty += wrong_penalty * wrong_attempts;
				int hh = (curr[3] - '0') * 10 + (curr[4] - '0');
				int mm = (curr[6] - '0') * 10 + (curr[7] - '0');
				int ss = (curr[9] - '0') * 10 + (curr[10] - '0');
				int seconds = hh * 60 * 60 + mm * 60 + ss;
				penalty += seconds;
			}
		}
		scores.push_back(make_pair(solved, make_pair(penalty, teamname)));
	}
	string teamname;
	cin >> teamname;
	string results[t];
	for (int i=0; i<t; i++) {
		cin >> results[i];
	}

	int solved = 0;
	int penalty = 0;
	for (int i=0; i<t; i++) {
		string curr = results[i];
		if (curr[0] == '-') {
			// can't have solved
		}
		else {
			// has solved if +
			int attempts = (curr[1] - '0');
			int wrong_attempts = attempts - 1;
			solved++;
			penalty += wrong_penalty * wrong_attempts;
			int hh = (curr[3] - '0') * 10 + (curr[4] - '0');
			int mm = (curr[6] - '0') * 10 + (curr[7] - '0');
			int ss = (curr[9] - '0') * 10 + (curr[10] - '0');
			int seconds = hh * 60 * 60 + mm * 60 + ss;
			penalty += seconds;
		}
	}
	scores.push_back(make_pair(solved, make_pair(penalty, teamname)));
	sort(scores.begin(), scores.end(), comp);
	
	for (int i=0; i<n; i++) {
		if (scores[i].second.second == us) cout << i+1 << endl;
	}
	
	
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 15 ms 504 KB Output is correct
3 Correct 5 ms 248 KB Output is correct
4 Correct 16 ms 760 KB Output is correct
5 Correct 16 ms 632 KB Output is correct