Advertisement
a_chn

Untitled

Jun 8th, 2024
447
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.22 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. void setIO(string s) {
  5.     ios_base::sync_with_stdio(0);
  6.     cin.tie(0);
  7.     freopen((s + ".in").c_str(), "r", stdin);
  8.     freopen((s + ".out").c_str(), "w", stdout);
  9. }
  10.  
  11. int main()
  12. {
  13.     setIO("badmilk");
  14.     int n, m, d, s;
  15.     cin >> n >> m >> d >> s;
  16.     map<pair<int, int>, int> mp;
  17.     vector<pair<int, int>> sick;
  18.     for(int i = 0; i < d; i++){
  19.         int p, m, t;
  20.         cin >> p >> m >> t;
  21.         mp[{p, m}] = t;
  22.     }
  23.     vector<pair<int, int>>milk;
  24.     for(auto& it : mp){
  25.         int p, t;
  26.         cin >> p >> t;
  27.         if(it.first.first == p && it.second < t){
  28.             milk.push_back({p, it.first.second});
  29.         }
  30.     }
  31.     int common=0;
  32.     if(milk.size()==1){
  33.         for(auto& it: milk){
  34.             common = it.second;
  35.         }
  36.     }
  37.     else{
  38.         map<int, int> com;
  39.         int freq = 0;
  40.         for(auto& it: milk){
  41.             com[it.second]++;
  42.             freq = max(freq, com[it.second]);
  43.         }
  44.         for(auto& it: com){
  45.             if(it.second==freq) common = it.first;
  46.         }
  47.     }
  48.     int count = 0;
  49.     for(auto& it: mp){
  50.         if(it.first.second==common) count++;
  51.     }
  52.     cout << count << '\n';
  53.     return 0;
  54. }
  55.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement