답안 #246058

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
246058 2020-07-08T06:14:51 Z Halit ACM (COCI19_acm) C++17
50 / 50
19 ms 512 KB
#include <bits/stdc++.h>
using namespace std;

long long to_seconds(string date);
bool name_cmp(string str1, string str2);

const long long penalty_time = 20 * 60;
const int N = 1000, M = 15;
const string Cro_Team = "NijeZivotJedanACM";

int n,m;
map<string, long long> points;
map<string, long long> solved_problems;

int main(){
	cin >> n >> m;
	for(int i = 1;i <= n;i++){
		string team_name;
		cin >> team_name;
		
		for(int j = 1;j <= m;j++){
			string verdict;
			cin >> verdict;
			if(equal(Cro_Team.begin(), Cro_Team.end(), team_name.begin() ) ){
				continue;
			}
			points[team_name] += to_seconds(verdict);
			solved_problems[team_name] += verdict[0] != '-';
		}
	}
	
	string useless;
	cin >> useless;
	for(int i = 1;i <= m;i++){
		string verdict;
		cin >> verdict;
		points[Cro_Team] += to_seconds(verdict);
		solved_problems[Cro_Team] += verdict[0] != '-';
	}
	
	auto cmp = [&](string str) -> bool{
		if(solved_problems[str] < solved_problems[Cro_Team]){
			return 0;
		} if(solved_problems[str] == solved_problems[Cro_Team]){
			return (points[str] == points[Cro_Team] ? name_cmp(Cro_Team,str) : points[str] <= points[Cro_Team] );
		}
		return 1;
	};
	
	long long ans = 0;
	for(auto it = points.begin(); it != points.end();it++){
		ans += cmp((*it).first);
	}
	
	cout << ans;
}

long long to_seconds(string date){
	if(date[0] == '-')
		return 0;
	
	long long s = penalty_time * (date[1] - '0' - 1);
	long long product = 60 * 60;
	for(int i = 3;i < date.size();i+=3){
		s += (((date[i] - '0') * 10) + (date[i+1] - '0')) * product;
		product /= 60;
	}
	
	return s;
}

bool name_cmp(string str1, string str2){
	for(int i = 0;i < str1.size();i++){
		if(str1[i] < str2[i])
			return 0;
		if(str1[i] > str2[i])
			return 1;
	}
	return 1;
}

Compilation message

acm.cpp: In function 'long long int to_seconds(std::__cxx11::string)':
acm.cpp:64:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i = 3;i < date.size();i+=3){
                ~~^~~~~~~~~~~~~
acm.cpp: In function 'bool name_cmp(std::__cxx11::string, std::__cxx11::string)':
acm.cpp:73:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i = 0;i < str1.size();i++){
                ~~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 18 ms 512 KB Output is correct
3 Correct 4 ms 256 KB Output is correct
4 Correct 19 ms 512 KB Output is correct
5 Correct 19 ms 512 KB Output is correct