/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 768.0 KiB
#2 Accepted 1ms 540.0 KiB
#3 Accepted 2ms 632.0 KiB
#4 Accepted 8ms 1.926 MiB
#5 Accepted 63ms 12.906 MiB
#6 Accepted 302ms 50.082 MiB
#7 Accepted 309ms 46.715 MiB
#8 Accepted 425ms 46.77 MiB
#9 Accepted 323ms 46.891 MiB
#10 Accepted 312ms 46.734 MiB

Code

#include <bits/stdc++.h>
using namespace std;
#define nl '\n'
#define f(i,s,n) for(int i = s; i < n; i++)
#define int long long

bool cmp(pair<int, int> p1, pair<int, int> p2){
    if(p1.first != p2.first)return p1.first > p2.first;
    return p1.second < p2.second;
}

void solve(){
    int d,j,g;cin>>d>>j>>g;
    int vacPainai = 0;
    map<string, int> mp;
    vector<int> agePrio(126, 0);
    f(i,0,j){
        string s;int p;
        cin>>s;cin>>p;
        mp[s] = p;
    }
    f(i,0,g){
        int l,u,p;cin>>l>>u>>p;
        for(int i = l; i <= u; i++)agePrio[i] = p;
    }
    int m = 0, n = 0;
    
    priority_queue<pair<int, int> > pq;
    vector<pair<pair<string, string>, int> > v;

    while(d--){
    // cout<<"ddd"<<nl;
        int tmpn,tmpm;cin>>tmpn>>tmpm;
        m += tmpm;
        for(int i = 0; i < tmpn; i++){
            int prio = 0;
            string nm, jb;int age;
            cin>>nm>>jb;cin>>age;
            prio = mp[jb] + agePrio[age];

            // cout<<nm<<" "<<mp[jb]<<" "<<agePrio[age]<<nl;
            v.push_back({{nm, jb}, age});
            pq.push({prio, -1 * (v.size() - 1)});
            // cout<<v.size()<<nl;
        }
        // while(!pq.empty() && m > 0) {
        //     pair<int,int> tp = pq.top();
        //     pq.pop();
        //     // cout<<tp.first<<" "<<v[-tp.second].first.first<<" "<<tp.second<<nl;
        //     m--;
        // }
        // cout<<nl;
        while(!pq.empty() && m > 0) {
            pair<int,int> tp = pq.top();
            pq.pop();
            // cout<<tp.second<<nl;
            string nm = v[-tp.second].first.first;
            string jb = v[-tp.second].first.second;
            int age = v[-tp.second].second;
             cout<<nm<<" "<<jb<<" "<<age<<nl;
             m--;
        }
        n = v.size();
    }
    cout<<"Still unvaccinated people: "<<pq.size()<<nl;
}

signed main() {
   ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
   int T = 1;
//    cin>>T;
   for(int tc = 1; tc <= T; 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:39:26
Judged At
2024-12-09 07:39:26
Judged By
Score
100
Total Time
425ms
Peak Memory
50.082 MiB