# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
253565 | MrRobot_28 | ACM (COCI19_acm) | C++17 | 7 ms | 1152 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
bool cmp(pair <pair <string, int>, int> a, pair <pair <string, int>, int> b)
{
if(a.first.second != b.first.second)
{
return a.first.second > b.first.second;
}
if(a.second != b.second)
{
return a.second < b.second;
}
return a.first.first + b.first.first < b.first.first + a.first.first;
}
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int n, m;
cin >> n >> m;
vector <pair <pair <string, int>, int> > mass;
vector <vector <string> > A(n, vector <string> (m + 1));
for(int i = 0; i < n; i++)
{
for(int j = 0; j < m + 1; j++)
{
cin >> A[i][j];
}
}
string s;
cin >> s;
int timer = 0;
int kol = 0;
for(int j = 0; j < m; j++)
{
string s1;
cin >> s1;
if(s1[0] == '+')
{
int cnt1 = 0, a = 0, b = 0, c = 0;
int flag = 0;
for(int j = 1; j < s1.size(); j++)
{
if(s1[j] == '/')
{
flag++;
}
else if(s1[j] == ':')
{
flag++;
}
else if(flag == 0)
{
cnt1 = cnt1 * 10 + (s1[j] - '0');
}
else if(flag == 1)
{
a = a * 10 + (s1[j] - '0');
}
else if(flag == 2)
{
b = b * 10 + (s1[j] - '0');
}
else
{
c = c * 10 + (s1[j] - '0');
}
}
kol++;
timer += a * 3600 + b * 60 + c + 1200 * cnt1;
}
}
mass.push_back({{s, kol}, timer});
for(int i = 0; i < n; i++)
{
if(A[i][0] == s)
{
continue;
}
int kol1 = 0;
int timer1 = 0;
for(int j = 1; j <= m; j++)
{
if(A[i][j][0] == '-')
{
continue;
}
int cnt1 = 0, a = 0, b = 0, c = 0;
int flag = 0;
for(int k = 1; k < A[i][j].size(); k++)
{
if(A[i][j][k] == '/')
{
flag++;
}
else if(A[i][j][k] == ':')
{
flag++;
}
else if(flag == 0)
{
cnt1 = cnt1 * 10 + (A[i][j][k] - '0');
}
else if(flag == 1)
{
a = a * 10 + (A[i][j][k] - '0');
}
else if(flag == 2)
{
b = b * 10 + (A[i][j][k] - '0');
}
else
{
c = c * 10 + (A[i][j][k] - '0');
}
}
timer1 += a * 3600 + b * 60 + c + 1200 * cnt1;
kol1++;
}
mass.push_back({{A[i][0], kol1}, timer1});
}
sort(mass.begin(), mass.end(), cmp);
for(int i = 0; i < mass.size(); i++)
{
if(mass[i].first.first == s)
{
cout << i + 1;
// return 0;
}
}
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |