Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- struct Stat{
- int rnd, cow, pts;
- };
- bool ascending_rnd(Stat a, Stat b){
- return a.rnd < b.rnd;
- }
- int main(){
- ifstream fin("mootimes.in");
- int N;
- fin >> N;
- vector<Stat> R(N);
- for(int i = 0; i<N; i++){
- int r, p;
- string c;
- fin >> r >> c >> p;
- R[i].rnd = r;
- if(c == "Bessie"){
- R[i].cow = 0;
- }else if(c == "Mildred"){
- R[i].cow = 1;
- }else{
- R[i].cow = 2;
- }
- R[i].pts = p;
- }
- sort(R.begin(), R.end(), ascending_rnd);
- vector<bool> leaderboard = {1, 1, 1};
- vector<int> P = {7, 7, 7};
- int ans = 0;
- for(int i = 0; i<N; i++){
- int max = 0;
- vector<int> ori(N);
- for(int j = 0; j<N; j++){
- ori[j] = leaderboard[j];
- }
- P[R[i].cow] += R[i].pts;
- for(int j = 0; j<3; j++){
- if(P[j] >= max){
- max = P[j];
- leaderboard[j] = true;
- }
- }
- for(int j = 0; j<3; j++){
- if(P[j] < max){
- leaderboard[j] = false;
- }
- }
- bool diff = false;
- //cout << "P: " << P[0] << " " << P[1] << " " << P[2] << ", leader board: " << leaderboard[0] << " " << leaderboard[1] << " " << leaderboard[2] << endl;
- for(int j = 0; j<3; j++){
- if(leaderboard[j] != ori[j]){
- diff = true;
- }
- }
- if(diff){
- ans++;
- }
- }
- cout << ans << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment