#include "bits/stdc++.h"
#define endl '\n'
#define pb push_back
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<int>::iterator vit;
typedef set<int> si;
typedef map<int, int> mii;
ll timeconv(string tim) {
ll sum = 0;
sum += (tim[1] - '0') * 60 * 60;
sum += ((tim[3] - '0') * 10 + (tim[4] - '0')) * 60;
sum += ((tim[6] - '0') * 10 + (tim[7] - '0'));
return sum;
}
struct datam {
ll win, time;
};
void solve() {
ll n, m, index = -1;
;
cin >> n >> m;
vector<pair<string, datam>> arr(n);
string ourteam = "NijeZivotJedanACM";
for (ll i = 0; i < n; i++) {
string temp;
cin >> temp;
if (temp == ourteam) {
index = i;
}
arr[i] = {temp, datam{0, 0}};
for (ll j = 0; j < m; j++) {
string temp2;
cin >> temp2;
if (temp2[0] == '-') {
continue;
}
arr[i].second.win++;
arr[i].second.time += 20 * 60 * (temp2[1] - '0' - 1);
arr[i].second.time += timeconv(temp2.substr(3));
}
}
string temp;
cin >> temp;
arr[index] = {temp, datam{0, 0}};
for (ll j = 0; j < m; j++) {
string temp2;
cin >> temp2;
if (temp2[0] == '-') {
continue;
}
arr[index].second.win++;
arr[index].second.time += 20 * 60 * (temp2[1] - '0' - 1);
arr[index].second.time += timeconv(temp2.substr(3));
}
ll ourwin = arr[index].second.win;
ll ourtime = arr[index].second.time;
ll ans=0;
if (n==1){
cout << 1 << endl;
return;
}
sort(all(arr), [](const auto &l, const auto &r) {
return l.second.win > r.second.win;
});
ll sol=0, sag=n;
bool seen=0;
for (ll i =0; i<arr.size();i++){
if (arr[i].second.win==ourwin && !seen){
seen =1;
sol=i;
}
if(seen && arr[i].second.win != ourwin){
sag = i;
break;
}
}
ans+=sol;
vector<pair<string,datam>> arr2(arr.begin()+sol,arr.begin()+sag);
sort(all(arr2), [](const auto &l, const auto &r) {
return l.second.time < r.second.time;
});
sol=0, sag=arr2.size();
seen=0;
for (ll i =0; i<arr2.size();i++){
if (arr2[i].second.time==ourtime && !seen){
seen =1;
sol=i;
}
if(seen && arr2[i].second.time != ourtime){
sag = i;
break;
}
}
ans+=sol;
vector<pair<string,datam>> arr3(arr2.begin()+sol,arr2.begin()+sag);
sort(all(arr3), [](const auto &l, const auto &r) {
return l.first < r.first;
});
seen =0;
for (ll i =0; i<(ll)arr3.size();i++){
if (arr3[i].first==ourteam && !seen){
seen =1;
sol=i;
}
}
ans +=sol;
cout << ans+1 << endl;
}
int main() {
std::ios::sync_with_stdio(false);
cin.tie(nullptr);
unsigned long long ct = 1;
// cin >> ct;
while (ct--)
solve();
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |