/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 540.0 KiB
#2 Accepted 1ms 540.0 KiB
#3 Accepted 3ms 632.0 KiB
#4 Accepted 11ms 904.0 KiB
#5 Accepted 77ms 4.715 MiB
#6 Accepted 413ms 20.695 MiB
#7 Accepted 394ms 10.691 MiB
#8 Accepted 342ms 10.57 MiB
#9 Accepted 347ms 10.488 MiB
#10 Accepted 346ms 10.574 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 {

   ll 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);
   ll d , j , g , job_priority , age , l , u , p , n , m ,availableVacine = 0 , rnk = 0 ; cin >> d >> j >> g ;
   string name , job ;
   map < string , ll > jobRank ;
   map < ll , ll > 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 ;
        ll priorityOfthisPerson = ageRank[age] + jobRank[job] ;
        pq.push({priorityOfthisPerson , rnk++ , age , name , job}) ;
      }
      ll cur = min(availableVacine , (ll) pq.size()) ;
      availableVacine -= cur ;
      while(cur > 0){
        auto it = pq.top() ;
        pq.pop() ;
        cout << it.name << " " << it.job << " " << it.age << "\n" ;
        cur-- ;
      }
   }
   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-10 11:39:53
Judged At
2024-12-10 11:39:53
Judged By
Score
100
Total Time
413ms
Peak Memory
20.695 MiB