#include <bits/stdc++.h>
using namespace std;
typedef pair<pair<int, int>, pair<pair<int, int>, string> > i5;
i5 mi5(int a, int b, int c, int d, string e){
return make_pair(make_pair(a,b),make_pair(make_pair(c,d),e));
}
int main(){
ios_base::sync_with_stdio(false);
int n, m;
cin >> n >> m;
//scanf("%d %d", &n, &m);
n++;
//char c;
//char texx[12] = "Hello world";
//string texx2 = texx;
//cin >> c;
bool tfself = true;
string teams[n];//, tsorted[n];
i5 stats[n];//questions (more is better), hours, minutes, seconds, name
for(int i = 0; i < n; i++){
//char tname[25];
//scanf("%s", &tname);
cin >> teams[i];
//teams[i] = tname;
//cout << teams[i];
//tsorted[i] = teams[i];
int qn, hr, mn, sc;
qn = hr = mn = sc = 0;
//char c2;
//cin >> c;
//scanf("%c", &c);
int att;
//cout << '\'' << c << '\'';
//bool ntrnc = true;
for(int j = 0; j < m; j++){
//scanf("%c", &c);
//printf("%c", c);
string qinfo;
cin >> qinfo;
//cout << c;
switch(qinfo[0]){
case '+':
case '?':
qn++;
//scanf("%c", &c);
att = 0;
att = (int)(qinfo[1]-'0');
mn += 20*att;
mn -= 20;
//scanf("%c", &c);
//printf("%c", c);
hr += 10*(int)(qinfo[3]-'0')+(int)(qinfo[4]-'0');
mn += 10*(int)(qinfo[6]-'0')+(int)(qinfo[7]-'0');
sc += 10*(int)(qinfo[9]-'0')+(int)(qinfo[10]-'0');
//ntrnc = true;
break;
case '-':
att = 0;
if(qinfo.size() > 1){
att = (int)(qinfo[1]-'0');
//mn += 20*att;
//scanf("%c", &c);
}
break;
default:
return 75;
}
}
if(teams[i] == "NijeZivotJedanACM" && tfself){
--i;
--n;
tfself = false;
continue;
}
mn += sc/60;
sc %= 60;
hr += mn/60;
mn %= 60;
stats[i] = mi5(-qn,hr,mn,sc,teams[i]);
}
sort(stats,stats+n);
for(int i = 0; i < n; i++){
//cout << stats[i].first.second << stats[i].second.first.first << stats[i].second.first.second << stats[i].second.second << endl;
if(stats[i].second.second == "NijeZivotJedanACM"){
cout << i+1;
return 0;
}
}
return 76;
}
/*
2 1
NijeZivotJedanACM -
ZivotJESTJedanACM -
NijeZivotJedanACM -
3 2
StoJeZivot ?1/04:00:00 +1/02:04:06
JeLiZivotJedanACM ?1/04:59:59 -
NijeZivotJedanACM ?1/04:42:43 -
NijeZivotJedanACM +1/04:42:43 -
*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
7 ms |
512 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
7 ms |
512 KB |
Output is correct |
5 |
Correct |
7 ms |
512 KB |
Output is correct |