/ SeriousOJ /

Record Detail

Memory Exceeded


  
# Status Time Cost Memory Cost
#1 Memory Exceeded ≥339ms ≥256.016 MiB
#2 Memory Exceeded ≥658ms ≥256.016 MiB

Code

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

#define endl "\n"
#define trace(x) cout << #x << ": " << x << endl
vector<pair<int,pair<int,pair<string,string>>>> pep,pep2;
map<string, int> mp;
bool cmp(pair<int,pair<int,pair<string,string>>> p, pair<int,pair<int,pair<string,string>>> q)
{
    if(p.first == q.first)
    {
        auto in1 = mp[p.second.second.first];
        auto in2 = mp[q.second.second.first];
        return in1 < in2;
    }
    return p.first > q.first;
}
int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int d,j,g;
    cin>>d>>j>>g;

    vector<pair<string,int>> job(j);
    for(auto &x : job)
    {
        cin>>x.first>>x.second;
    }

    vector<pair<int,int>> age(g);
    for(auto &x : age)
    {
        int y;
        cin>>y>>x.first>>x.second;
    }

    int vec = 0;
    int cnt  = 1;
    while(d--)
    {
        int n,m;
        cin>>n>>m;
        vec+=m;
        while(n--)
        {
            string s1,s2;
            int ag;
            cin>>s1>>s2>>ag;
            mp[s1] = cnt;
            cnt++;
            int pra=0;
            for(int i = 0; i < j; i++)
            {
                if(s2==job[i].first)
                {
                    pra += job[i].second;
                    break;
                }
            }
            for(int i = 0; i < g; i++)
            {
                if(ag < age[i].first){
                    pra += age[i].second;
                    break;
                }
            }
            pep.push_back({pra,{ag,{s1,s2}}});
        }
        sort(pep.begin(),pep.end(), cmp);
        while(m--)
        {
            // pep2.push_back(pep[0]);
            cout<<pep[0].second.second.first<<" "<<pep[0].second.second.second<<" "<<pep[0].second.first<<endl;
            pep.erase(pep.begin());
        }
    }
    cout<<"Still unvaccinated people: "<<pep.size()<<endl;
    // for(auto v: pep2)
    // {
    //     cout<<v.first<<" "<<v.second.second.first<<" "<<v.second.second.second<<" "<<v.second.first<<endl;
    // }
    return 0;
}


// Jonah Doctor 24
// Hillary Nurse 43
// Alex Nurse 44
// Gandhi Doctor 24
// Xavier Businessman 67
// James Engineer 45
// Still unvaccinated people: 1

Information

Submit By
Type
Submission
Problem
P1149 Swap and Minimize
Contest
LU IUJPC : Sylhet Division 2024
Language
C++17 (G++ 13.2.0)
Submit At
2024-12-09 09:43:23
Judged At
2024-12-09 09:43:23
Judged By
Score
0
Total Time
≥658ms
Peak Memory
≥256.016 MiB