/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 540.0 KiB
#2 Accepted 1ms 540.0 KiB
#3 Accepted 3ms 796.0 KiB
#4 Accepted 16ms 1.02 MiB
#5 Accepted 133ms 4.57 MiB
#6 Accepted 688ms 18.633 MiB
#7 Accepted 619ms 10.648 MiB
#8 Accepted 589ms 10.402 MiB
#9 Accepted 591ms 10.586 MiB
#10 Accepted 605ms 10.609 MiB

Code

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace __gnu_pbds;
using namespace std;
 
#define inf 1013161010
#define mod 1000000007
#define mod1 998244353
#define ll long long
#define lf long double
#define sz(x) ((int)x.size())
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,a,b) for(ll i=a;i<=b;i++)
#define fr freopen("x.txt","r",stdin)
#define frc freopen("y.txt","w",stdout)
#define all(x) x.begin(),x.end()
#define set0(x) memset(x,0,sizeof(x))
#define dbg cout<<"yo "<<endl;
#define pset(n) fixed<<showpoint<<setprecision(n)
#define endl '\n'
 
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vpii vector<pair<int,int> >
#define vll vector<ll>
#define vpll vector<pair<ll,ll> >
#define si set<int>
#define mii map<int,int>
#define umii unordered_map<int,int>
#define vi vector<int>
#define pb push_back
#define ff first
#define ss second
 
template<class T>
using min_pq = priority_queue<T,vector<T>,greater<T>>;
 
typedef tree<pii,null_type,less<pii>,rb_tree_tag,tree_order_statistics_node_update> OST;
 
ll toint(const string &s) { stringstream ss; ss << s; ll x; ss >> x; return x; }
string tostring ( ll number ){  stringstream ss; ss<< number; return ss.str();}
 
const lf pi = 2*acos(0);
const int nn = 500006;
const lf EPS = 0.000000001;
 
ll gcd(ll a,ll b){return (b==0)? a:gcd(b,a%b); }
ll fast_pow(ll a,ll m, ll mode) { if(m==0) return 1; else if(m==1) return a; ll h=fast_pow(a,m/2,mode); if(m%2==0) return ((h*h)%mode); else return ((((h*h)%mode)*a)%mode);}
ll mmi(ll b, ll mode){return fast_pow(b, mode-2, mode);}
 
struct Person {
    int priority;
    string name;
    string job;
    int age;
    int pindex;

    Person(int p, string n, string j, int a, int i) : priority(p), name(n), job(j), age(a), pindex(i) {}

    bool operator<(const Person& other) const {
        if (priority == other.priority) 
            return pindex > other.pindex;
        return priority < other.priority;
    }
};

int main() {
    int t = 1;
    // cin >> t;
 
    while (t--) {
        ll n=0, j, g, d, l, u, p, x, r, age, m;
        cin >> d >> j >> g;
        string job, name;
        vector<pair<pair<int, int>, int> > groups;
        unordered_map<string, int> mp;
        rep(i, j) {
            cin >> job >> p;
            mp[job] = p;
        }
        rep(i, g) {
            cin >> l >> u >> p;
            groups.pb({{l, u}, p});
        }
        
        priority_queue<Person> pq;
        int total = 0;
        int idx = 0;
        rep(i, d) {
            cin >> n >> m;
            total += m;
            rep(j, n) {
                cin >> name >> job >> age;
                int priority = 0;
                if (mp.find(job) != mp.end()) {
                    priority += mp[job];
                }
                rep(k, g) {
                    if (age >= groups[k].ff.ff and age <= groups[k].ff.ss) {
                        priority += groups[k].ss;
                    }
                }
                // cout << priority << endl;
                pq.push(Person(priority, name, job, age, idx));
                idx++;
            }
            while(!pq.empty()) {
                if (total == 0) {
                    break;
                }
                Person person = pq.top();
                pq.pop();
                cout << person.name << " " << person.job << " " << person.age << endl;
                total--;
            }
        }
        cout << "Still unvaccinated people: " << sz(pq) << endl;        
        
    }
    return 0;
}
 

Information

Submit By
Type
Submission
Problem
P1148 e-Vaccine
Contest
LU IUJPC : Sylhet Division 2024 Replay Contest
Language
C++17 (G++ 13.2.0)
Submit At
2024-12-10 11:36:43
Judged At
2024-12-10 11:36:43
Judged By
Score
100
Total Time
688ms
Peak Memory
18.633 MiB