/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 2ms 324.0 KiB
#2 Accepted 2ms 332.0 KiB
#3 Accepted 4ms 628.0 KiB
#4 Accepted 16ms 1004.0 KiB
#5 Accepted 156ms 4.617 MiB
#6 Accepted 830ms 18.777 MiB
#7 Accepted 682ms 10.605 MiB
#8 Accepted 647ms 10.672 MiB
#9 Accepted 633ms 10.672 MiB
#10 Accepted 637ms 10.688 MiB

Code

#include <bits/stdc++.h>
using namespace std;
#define SC               scanf
#define PF               printf
#define ull              unsigned long long
#define ld               long double
#define F                first
#define S                second
#define pb               push_back
#define sort_a(a)        sort(a.begin(),a.end());
#define sort_d(a)        sort(a.rbegin(),a.rend());
#define READ(f)          freopen(f, "r", stdin)
#define WRITE(f)         freopen(f, "w", stdout)
#define rev(s)           reverse(s.begin(),s.end())
#define P(ok)            cout << (ok ? "YES\n": "NO\n")
#define __Heart__              ios_base :: sync_with_stdio(false); cin.tie(NULL);
#define ll long long
typedef pair< ll , ll>                   PII;
struct heart {

   int priority , position , age  ;
   string name , job ;
};

bool compare(const heart& a, const heart& b) {
    if (a.priority != b.priority) return a.priority < b.priority;
    return a.position > b.position;
}
void solve()
{
   priority_queue<heart, vector<heart>, decltype(&compare)> pq(compare);
   int d , j , g , job_priority , age , l , u , p , n , m ,availableVacine = 0 , rnk = 0 ; cin >> d >> j >> g ;
   string name , job ;
   map < string , int > jobRank ;
   map < int , int > ageRank ;
   for(int i = 0 ; i < j ; i++){
     cin >> job >> job_priority ;
     jobRank[job] = job_priority ;
   }
   for(int i = 0 ; i < g ; i++) {
     cin >> l >> u >> p ;
     for(int j = l ; j <= u ; j++) ageRank[j] = p ;
   }
   while(d--){
      cin >> n >> m ;
      availableVacine += m ;
      for(int i = 0 ; i < n ; i++){
        cin >> name >> job >> age ;
        int priorityOfthisPerson = ageRank[age] + jobRank[job] ;
        pq.push({priorityOfthisPerson , rnk++ , age , name , job}) ;
      }
      int cur = min(availableVacine , (int) pq.size()) ;
      availableVacine -= cur ;
      while(cur-- && cur >= 0){
        auto it = pq.top() ;
        pq.pop() ;
        cout << it.name << " " << it.job << " " << it.age << "\n" ;
      }
   }
   cout << "Still unvaccinated people: " << pq.size() << "\n" ;
}
int main()
{
     __Heart__
     //READ("0in.txt") ;
    // WRITE("0out.txt") ;
     int t ; t = 1; while(t--) solve() ;
}

Information

Submit By
Type
Submission
Problem
P1148 e-Vaccine
Language
C++17 (G++ 13.2.0)
Submit At
2024-12-09 08:24:51
Judged At
2024-12-09 09:00:51
Judged By
Score
100
Total Time
830ms
Peak Memory
18.777 MiB