/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 540.0 KiB
#2 Wrong Answer 1ms 516.0 KiB
#3 Accepted 3ms 724.0 KiB
#4 Accepted 14ms 1.012 MiB
#5 Accepted 119ms 4.57 MiB
#6 Wrong Answer 652ms 26.93 MiB

Code

#include <bits/stdc++.h>
using namespace std;

typedef int64_t ll;

#ifdef LOCAL
#include "debug.hpp"
#else
#define debug(...) 42
#endif

map<string, ll> mp;
map<ll, pair<ll, ll>> mp1;

struct A {
    string name, job;
    ll age;
    A(string name, string job, ll age)
        : name{name}, job{job}, age{age} {
    }
    ll get_priority() {
        ll v = 0;
        v += mp[job];
        auto itr = mp1.lower_bound(age);
        if (itr != mp1.end() && itr->second.first <= age)
            v += itr->second.second;
        return v;
    }
};

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll d, j, g;
    cin >> d >> j >> g;
    for (ll i = 0; i < j; i++) {
        string job;
        ll v;
        cin >> job >> v;
        mp[job] = v;
    }
    for (ll i = 0; i < g; i++) {
        ll l, r, p;
        cin >> l >> r >> p;
        mp1[r] = {l, p};
    }
    function<bool(tuple<ll, ll, A>, tuple<ll, ll, A>)> comparator = [](const tuple<ll, ll, A> &t1, const tuple<ll, ll, A> &t2) -> bool {
        ll p1 = get<0>(t1), p2 = get<0>(t2);
        ll idx1 = get<1>(t1), idx2 = get<1>(t2);
        if (p1 != p2)
            return p1 < p2;
        return idx1 > idx2;
    };
    priority_queue<tuple<ll, ll, A>, vector<tuple<ll, ll, A>>, decltype(comparator)> pq(comparator);
    ll cnt = 0;
    for (ll i = 0; i < d; i++) {
        ll n, m;
        cin >> n >> m;
        for (ll i = 0; i < n; i++) {
            string name, job;
            ll age;
            cin >> name >> job >> age;
            A a(name, job, age);
            pq.push({a.get_priority(), cnt++, a});
        }
        for (ll i = 0; i < m; i++) {
            if (pq.empty())
                continue;
            A a = get<2>(pq.top());
            pq.pop();
            cout << a.name << ' ' << a.job << ' ' << a.age << '\n';
        }
    }
    cout << "Still unvaccinated people: " << pq.size() << '\n';
}

Information

Submit By
Type
Submission
Problem
P1148 e-Vaccine
Language
C++17 (G++ 13.2.0)
Submit At
2024-12-12 12:45:09
Judged At
2024-12-12 12:45:09
Judged By
Score
30
Total Time
652ms
Peak Memory
26.93 MiB