Source Code
/*
     Author: Asmaa Raafat
*/
/////////////////////////////"THINK TWICE... CODE ONCE"/////////////////////////////////.
#include <bits/stdc++.h>
#define ll long long
#define fast ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
/*ll freqfac[22] ={1};
void getfac(int n)
{
    for(int i=1; i<=20; i++)
    {
        freqfac[i] = freqfac[i-1] * i;
    }
}*/
int main()
{
    #ifndef ONLINE_JUDGE
    //freopen("primes.in", "r", stdin);
    #endif
    fast;
    int t;
    cin>>t;
    while(t--)
    {
        ll n;
        cin>>n;
        ll arr[n];
        ll cnt =0;
        for(int i=0; i<n; i++)
        {
            cin>>arr[i];
        }
        ll m = arr[n-1];
        for(int i=0; i<n-1; i++)
        {
            if(arr[i] == m)
            {
                cnt ++;
            }
        }
        if(cnt>0)
        {
            cout<<cnt+1<<endl;
        }
        else
        {
            cout<<n<<endl;
        }
    }
}
/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1?)
	* do smth instead of nothing and stay organized
	* WRITE STUFF DOWN
	* DON'T GET STUCK ON ONE APPROACH
*/
Copy
Proud Competitors asmaa_raafat
GNU G++17
44 ms
256 KB
Wrong Answer