Submission #206385

# Submission time Handle Problem Language Result Execution time Memory
206385 2020-03-03T07:28:30 Z wiwiho ACM (COCI19_acm) C++14
50 / 50
9 ms 632 KB
//#define NDEBUG

#include <bits/stdc++.h>
#include <bits/extc++.h>

#define StarBurstStream ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define iter(a) a.begin(), a.end()
#define riter(a) a.rbegin(), a.rend()
#define lsort(a) sort(iter(a))
#define gsort(a) sort(riter(a))
#define mp(a, b) make_pair(a, b)
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define pf(a) push_front(a)
#define pob pop_back()
#define pof pop_front()
#define F first
#define S second
#define printv(a, b) {bool pvaspace=false; \
for(auto pva : a){ \
    if(pvaspace) b << " "; pvaspace=true;\
    b << pva;\
}\
b << "\n";}
#define pii pair<int, int>
#define pll pair<ll, ll>
#define tiii tuple<int, int, int>
#define mt make_tuple
#define gt(t, i) get<i>(t)
#define iceil(a, b) ((a) / (b) + !!((a) % (b)))

//#define TEST

typedef long long ll;
typedef unsigned long long ull;

using namespace std;
using namespace __gnu_pbds;

const ll MOD = 1000000007;
const ll MAX = 2147483647;

template<typename A, typename B>
ostream& operator<<(ostream& o, pair<A, B> p){
    return o << '(' << p.F << ',' << p.S << ')';
}

pii trans(string str){
    pii a;
    a.S = str[1] - '0';
    a.F = stoi(str.substr(3, 2)) * 3600 + stoi(str.substr(6, 2)) * 60 + stoi(str.substr(9, 2));
    return a;
}

bool comp(pair<pii, string> a, pair<pii, string> b){
    if(a.F.F != b.F.F) return a.F.F > b.F.F;
    else if(a.F.S != b.F.S) return a.F.S < b.F.S;
    else return a.S < b.S;
}

int main(){
    StarBurstStream

    int n, m;
    cin >> n >> m;

    int id = -1;
    vector<pair<pii, string>> s(n);

    for(int i = 0; i < n; i++){
        string name;
        cin >> name;
        s[i].S = name;

        if(name == "NijeZivotJedanACM"){
            id = i;
            for(int j = 0; j < m; j++){
                string str;
                cin >> str;
            }
            continue;
        }

        int p = 0, t = 0;
        for(int j = 0; j < m; j++){
            string str;
            cin >> str;
            if(str[0] == '-') continue;
            pii tt = trans(str);
            t++, p += tt.F + (tt.S - 1) * 1200;
        }
        s[i].F = mp(t, p);
    }

    string name;
    cin >> name;
    int p = 0;
    int t = 0;
    for(int j = 0; j < m; j++){
        string str;
        cin >> str;
        if(str[0] != '+') continue;
        pii tt = trans(str);
        t++, p += tt.F + (tt.S - 1) * 1200;
    }
    s[id].F = mp(t, p);

//    for(auto i : s) cerr << i << "\n";

    sort(iter(s), comp);

    for(int i = 0; i < n; i++){
        if(s[i].S == "NijeZivotJedanACM"){
            cout << i + 1 << "\n";
            break;
        }
    }

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 504 KB Output is correct
2 Correct 9 ms 632 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 9 ms 508 KB Output is correct
5 Correct 9 ms 632 KB Output is correct