/ SeriousOJ /

Record Detail

Runtime Error


  
# Status Time Cost Memory Cost
#1 Accepted 2ms 540.0 KiB
#2 Runtime Error 2ms 564.0 KiB
#3 Runtime Error 3ms 588.0 KiB

Code

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

#define nl '\n'
#define ll long long
// #define int long long
#define pii pair<int, int> 



void solve(){
    int d,j,g; cin >> d >> j >>g;
    // prio, -id, name
    map<string, int> a;
    for(int i=0;i<j;++i) {
        string s; int p;
        cin >> s >> p;
        a[s] = p;
    }
    vector<pii> rng;
    map<pii, int> rngPrio;
    while(g--) {
        int l,r,p; cin >> l >> r >> p;
        rng.push_back(make_pair(l,r));
        rngPrio[{l, r}] = p;
    }
    sort(rng.begin(), rng.end());
    // for(auto [p, q]: rngPrio) cout << p.first << " " << p.second << " " << q << endl;
    // int q; cin  >> q;
    // int id = 0;
    // prio, id, name
    set<tuple<int, int, string>> li; 
    map<string, int> ids;
    int id = 1;
    while(d--) {
        int n, m; cin >> n >> m;
        while(n--){
            string s, t; int age;
            cin >> s >> t >> age;

            int cur = a[t];

            auto lbid = upper_bound(rng.begin(), rng.end(), make_pair(age, (int)-2e9)) - rng.begin();
            // cout << lbid << " ";
            if(lbid != 0){
                lbid--;
                if(rng[lbid].first <= age and rng[lbid].second>=age){
                    cur += rngPrio[{rng[lbid].first, rng[lbid].second}];
                }
                // cout << cur << endl;
            }
            string tot = s + " " + t + " " + to_string(age);
            // string tot = "";
            li.insert({cur, -id, tot});
            id++;
        }
        // for(auto [xx,xxx,xxxx]: li) cerr << xx << " " << xxx << " " << xxxx << endl;
        // cerr << endl;
        while(m--){
            auto [Pro, id, name] = *li.rbegin();
            li.erase(li.find(*li.rbegin()));
            cout << name << nl;
            // cout << endl;
            // cout << endl;
        }
    }
    cout << "Still unvaccinated people: " << (int)li.size() << nl;
}

int32_t main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int t = 1, tc = 0;
    // cin >> t ;
    while(t--){
        // cout << "Case " << ++tc  << ": ";
        solve();
    }
    return 0;
}

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 06:45:18
Judged At
2024-12-09 09:01:21
Judged By
Score
0
Total Time
3ms
Peak Memory
588.0 KiB