Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- void setIO(string s) {
- ios_base::sync_with_stdio(0);
- cin.tie(0);
- freopen((s + ".in").c_str(), "r", stdin);
- freopen((s + ".out").c_str(), "w", stdout);
- }
- int main()
- {
- setIO("badmilk");
- int n, m, d, s;
- cin >> n >> m >> d >> s;
- map<pair<int, int>, int> mp;
- vector<pair<int, int>> sick;
- for(int i = 0; i < d; i++){
- int p, m, t;
- cin >> p >> m >> t;
- mp[{p, m}] = t;
- }
- vector<pair<int, int>>milk;
- for(auto& it : mp){
- int p, t;
- cin >> p >> t;
- if(it.first.first == p && it.second < t){
- milk.push_back({p, it.first.second});
- }
- }
- int common=0;
- if(milk.size()==1){
- for(auto& it: milk){
- common = it.second;
- }
- }
- else{
- map<int, int> com;
- int freq = 0;
- for(auto& it: milk){
- com[it.second]++;
- freq = max(freq, com[it.second]);
- }
- for(auto& it: com){
- if(it.second==freq) common = it.first;
- }
- }
- int count = 0;
- for(auto& it: mp){
- if(it.first.second==common) count++;
- }
- cout << count << '\n';
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement