#include <bits/stdc++.h>
using namespace std;
int timetoscore(string time, int start){
return (time[start]-'0')*36000+(time[start+1]-'0')*3600+(time[start+3]-'0')*600+(time[start+4]-'0')*60+(time[start+6]-'0')*10+(time[start+7]-'0');
}
int comp_str(string s1, string s2){
for(int i=0;i<min(s1.length(), s2.length());i++){
if(s1[i] < s2[i])
return 1;
if(s1[i] > s2[i])
return 2;
}
if(s1.length() == s2.length())
return 0;
if(s1.length() < s2.length())
return 1;
return 2;
}
int main(){
int n, m; cin>>n>>m;
vector<pair<string, vector<string>>> res = vector<pair<string, vector<string>>>(n, pair<string, vector<string>>());
for(int i=0;i<n;i++){
cin >> res[i].first;
res[i].second.resize(m);
for(int j=0;j<m;j++){
cin >> res[i].second[j];
}
}
int solves=0;
int penalty=0;
string team; cin >> team;
for(int i=0;i<m;i++){
string cur_res;
cin >> cur_res;
if(cur_res[0] == '-')
continue;
solves++;
if(cur_res[1] == '/')
penalty += timetoscore(cur_res, 2);
else
penalty += timetoscore(cur_res, 3) + (cur_res[1]-'0')*1200;
}
int place = 1;;
for(auto person:res){
if(comp_str(person.first,team) == 0)
continue;
int m_solves=0;
int m_penalty=0;
for(int i=0;i<m;i++){
if(person.second[i][0] == '-')
continue;
m_solves++;
if(person.second[i][1] == '/')
m_penalty += timetoscore(person.second[i], 2);
else
m_penalty += timetoscore(person.second[i], 3) + (person.second[i][1]-'0')*1200;
}
if(m_solves > solves)
place++;
if(m_solves != solves)
continue;
if(m_penalty < penalty)
place++;
if(m_penalty != penalty)
continue;
if(comp_str(person.first, team) == 1){
place++;
continue;
}
}
cout << place << '\n';
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |