/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 540.0 KiB
#2 Accepted 1ms 540.0 KiB
#3 Accepted 3ms 608.0 KiB
#4 Accepted 8ms 728.0 KiB
#5 Accepted 53ms 3.977 MiB
#6 Accepted 344ms 18.125 MiB
#7 Accepted 353ms 10.613 MiB
#8 Accepted 349ms 10.535 MiB
#9 Accepted 351ms 10.617 MiB
#10 Accepted 358ms 10.648 MiB

Code

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


#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

template<typename T> using o_set = tree<T, null_type, std::less<T>, 
rb_tree_tag, tree_order_statistics_node_update>;

struct st {
    int age;
    string name, job;
    
};

void solve() {
    int d, j, g;
    cin >> d >> j >> g;

    map<string, int> jobP;
    for (int i = 0; i < j; i++) {
        string s;
        int p;
        cin >> s >> p;
        jobP[s] = p;
    }

    vector<pair<pair<int, int>, int>> ageP(g);
    for (int i = 0; i < g; i++) {
        int l, r, p;
        cin >> l >> r >> p;
        ageP[i] = {{l, r}, p};
    }

    int curVac = 0, taken = 0, tot = 0;
    priority_queue<int> pq;
    //multiset<st, cmp()> ms;
    map<int, queue<st>> mp;
    for (int i = 1; i <= d; i++) {
        int n, vac;
        cin >> n >> vac;
        curVac += vac;
        tot += n;

        for (int k = 1; k <= n; k++) {
            string name, job;
            int age, p = 0;
            cin >> name >> job >> age;

            for (int kk = 0; kk < g; kk++) {
                if(ageP[kk].first.first <= age and ageP[kk].first.second >= age) {
                    p = ageP[kk].second;
                    break;
                }
            }

            pq.push(p + jobP[job]);
            //cout << p + jobP[job] << '\n'; 
            st vari;
            vari.name = name;
            vari.job = job;
            vari.age = age; 
            mp[p + jobP[job]].push(vari);
        }

        while(!pq.empty() and curVac) {
            int tp = pq.top();
            //while(mp[tp])
            //if(!curVac and !mp[tp].empty())
            st ans = mp[tp].front();
            cout << ans.name << " " << ans.job << " " << ans.age << '\n';
            mp[tp].pop();
            pq.pop();
            curVac--;
            taken++;
        }
 
    }
    cout << "Still unvaccinated people: " << tot - taken << '\n';

}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int t = 1; 
    //cin>>t;
    for(int tc = 1; tc <= t; tc++) {
        // cout<<"Case "<<tc<<":";
        solve();
    }
}

Information

Submit By
Type
Submission
Problem
P1148 e-Vaccine
Contest
LU IUJPC : Sylhet Division 2024
Language
C++17 (G++ 13.2.0)
Submit At
2024-12-09 07:47:59
Judged At
2024-12-10 08:37:01
Judged By
Score
100
Total Time
358ms
Peak Memory
18.125 MiB