Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- #define F first
- #define S second
- #define pb push_back
- #define ll long long
- vector < pair < int,pair <string,int> > > a;
- int ans = 0;
- int mildred = 7, elsie = 7, bessie =7;
- int main() {
- ios_base::sync_with_stdio(0);
- cin.tie(0);
- cout.tie(0);
- freopen("input.txt", "r", stdin);
- freopen("output.txt", "w", stdout);
- int n;
- cin >> n;
- int d, k;
- string nn;
- for(int i = 0 ; i < n; i++) {
- cin >> d >> nn >> k;
- a.pb({d,{nn,k}});
- }
- set <int> s;
- s.insert(1);
- s.insert(2);
- s.insert(3);
- sort(a.begin(),a.end());
- for(int i = 0 ; i < n; i++) {
- ll mx = -1e14;
- if(a[i].S.F=="Mildred")mildred+=a[i].S.S;
- if(a[i].S.F=="Bessie")bessie+=a[i].S.S;
- if(a[i].S.F=="Elsie")elsie+=a[i].S.S;
- mx=max(mildred, max(elsie, bessie));
- set<int> ss;
- if(elsie==mx) ss.insert(3);
- if(bessie==mx) ss.insert(2);
- if(mildred==mx) ss.insert(1);
- if(s!=ss) {
- ans++;
- s=ss;
- }
- }
- cout << ans;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement