Help in "milk measurement"

Checklist

Make sure to read all of How to ask for help on a problem before asking for help.

Problem Info

Milk Measurement USACO

Question

Hi, i implemented the solution for the milk measurement problem, but i keep getting error in four test cases even though i am trying to find some error in my code since 1 hour ago. could someone please help me to find where is the error in my code?

What I’ve Tried

i am trying to find some error in my code since 1 hour ago. could someone please help me to find where is the error in my code?

My Work

#include <bits/stdc++.h> // see /general/running-code-locally
using namespace std;

using ll = long long;

using vi = vector;
#define pb push_back
#define all(x) begin(x), end(x)
#define sz(x) (int) (x).size()

using pi = pair<int,int>;
#define f first
#define s second
#define mp make_pair

void setIO(string name = “”) {
cin.tie(0)->sync_with_stdio(0); // see /general/fast-io
if (sz(name)) {
freopen((name + “.in”).c_str(), “r”, stdin); // see /general/input-output
freopen((name + “.out”).c_str(), “w”, stdout);
}
}

// changes[c][d] is the change in milk rate for cow c on day d
// rates[c][d] is the milk rate for cow c on day d
const int MAX_D = 100;
int rates[3][MAX_D+1];
int change[3][MAX_D+1];

// Is cow c the highest on day d?

bool is_highest(int c, int d){
int highest = max(max(rates[0][d], rates[1][d]), rates[2][d]);
return rates[c][d] == highest;
}
int main(void) {

setIO("measurement");

int n,dia,dif,c=0;
string vaca;
cin>>n;
for(int r=0;r<n;r++){
    cin>>dia;
    cin>>vaca;
    cin>>dif;
    if(vaca=="Bessie") change[0][dia]=dif;
    if(vaca=="Elsie") change[1][dia]=dif;
    if(vaca=="Mildred") change[2][dia]=dif;
        

}
for(int z=0;z<3;z++) rates[z][0] = 7;

bool bessie = 0;
bool elsie = 0;
bool mildred = 0;

for(int i=1;i<(101);i++){
    
    for(int j=0;j<3;j++){
        rates[j][i]= rates[j][i-1] + change[j][i];
    }

    if((is_highest(0,i)!=bessie) || (is_highest(1,i)!=elsie) || (is_highest(2,i)!=mildred)){
        c++;
        bessie=is_highest(0,i);
        elsie=is_highest(1,i);
        mildred=is_highest(2,i); 
    } 

}
cout<<c<<endl;

}

^