Sample Test Case passes in Visual Studio Code but doesn't in Analysis Mode

2017-December-Bronze-Question 3

#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>

using namespace std;

struct tup
{
    int day, change;
    char who; // Order: B E M with the first letter of the names representing each cow
}; // each event

bool comp(tup one, tup two);
int where(int* pointer, int high);

int main()
{
    freopen("measurement.in", "r", stdin);
    freopen("measurement.out", "w", stdout); // file input & output

    int N, arr[3] = {7, 7, 7}, cur[2] = {3, 3}, res = 0; 
    cin >> N;

    tup events[N];
    for (int i = 0; i < N; ++i)
    {
        string pass;
        cin >> events[i].day >> pass >> events[i].change;

        events[i].who = pass[0];
    } // getting input

    sort(events, events + N, comp); // processing in order

    for (tup event : events)
    {
        if (event.who == 'B')
        {
            arr[0] += event.change;
        }
        else if (event.who == 'E')
        {
            arr[1] += event.change;
        }
        else
        {
            arr[2] += event.change;
        } // make the change in milk production

        int high = max(max(arr[0], arr[1]), arr[2]); // max milk production
        int now[2];
        now[0] = count(arr, arr + 3, high); // number of cows with max milk production
        int place = where(arr, high); // first cow the has the max milk production

        if (now[0] == 1)
        {
            now[1] = place;
        }
        else if (now[0] == 3)
        {
            now[1] = 3;
        }
        else
        {
            if (place == 1)
            {
                now[1] = 0;
            }
            else
            {
                if (arr[1] == high)
                {
                    now[1] = 2;
                }
                else
                {
                    now[1] = 1;
                }
            }
        } // creating the 'now' representing posters, with now[1] = 3 if now[0] == 3, else now[1] = the outlier

        if ((cur[0] != now[0]) || (cur[1] != now[1]))
        {
            cur[0] = now[0];
            cur[1] = now[1];

            ++res;
        } // if change in display is needed then update current and update counter
    }

    cout << res << endl;

    return 0;
}

bool comp(tup one, tup two)
{
    return one.day < two.day;
} // comparison function for tup

int where(int* pointer, int high)
{
    for (int i = 0; i < 3; ++i)
    {
        if (*pointer == high)
        {
            return i;
        }
    }
} // function to find where the value 'high' first appears in 'arr'

I tried the sample test case on Visual Studio Code and my program generates the correct output(3) but when I actually submit it in analysis mode I get the following:


May someone please explain this? Any help is very much appreciated :pray::pray::pray:.

^

Problem resolved. Thank you very much :pray::pray::pray:.