답안 #815907

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
815907 2023-08-09T02:18:55 Z tlnk07 ACM (COCI19_acm) C++17
50 / 50
4 ms 980 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long

long long n, m;
string s[1005][20];
struct ban
{
    string name;
    int q, p;
    ban()
    {
        q = p = 0;
    }
} a[1005];
bool operator<(const ban& a, const ban& b)
{
    if (a.q > b.q)
        return true;
    if (a.q < b.q)
        return false;
    if (a.p < b.p)
        return true;
    if (a.p > b.p)
        return false;
    return a.name < b.name;
}
 
signed main()
{
    cin >> n >> m;
    for (int i = 1; i <= n + 1; ++i)
    {
        cin >> a[i].name;
        for (int j = 1; j <= m; ++j)
            cin >> s[i][j];
    }
    for (int i = 1; i <= n; ++i)
    {
        if (a[i].name == a[n + 1].name)
        {
            for (int j = 1; j <= m; ++j)
            {
                if (s[n + 1][j][0] != '-')
                {
                    ++a[i].q;
                    a[i].p += (s[n + 1][j][1] - '0') * 20 * 60;
                    a[i].p += ((s[n + 1][j][3] - '0') * 10 + (s[n + 1][j][4] - '0')) * 60 * 60;
                    a[i].p += ((s[n + 1][j][6] - '0') * 10 + (s[n + 1][j][7] - '0')) * 60;
                    a[i].p += ((s[n + 1][j][9] - '0') * 10 + (s[n + 1][j][10] - '0'));
                }
            }
        }
        else
        {
            for (int j = 1; j <= m; ++j)
            {
                if (s[i][j][0] != '-')
                {
                    ++a[i].q;
                    a[i].p += (s[i][j][1] - '0') * 20 * 60;
                    a[i].p += ((s[i][j][3] - '0') * 10 + (s[i][j][4] - '0')) * 60 * 60;
                    a[i].p += ((s[i][j][6] - '0') * 10 + (s[i][j][7] - '0')) * 60;
                    a[i].p += ((s[i][j][9] - '0') * 10 + (s[i][j][10] - '0'));
                }
            }
        }
    }
    sort(a + 1, a + n + 1);
    for (int i = 1; i <= n; ++i)
    {
        if (a[i].name == a[n + 1].name)
        {
            cout << i;
            return 0;
        }
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 980 KB Output is correct
2 Correct 4 ms 980 KB Output is correct
3 Correct 1 ms 852 KB Output is correct
4 Correct 4 ms 980 KB Output is correct
5 Correct 4 ms 980 KB Output is correct