HTML & JS
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define be begin()
#define en end()
#define le length()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (__typeof(n) i = 0; i < n; i++)
#define repo(i, n) for (__typeof(n) i = 1; i <= n; i++)
#define eps 1e-6
#define pi 3.141592653589793
#define c(a) cout << a << "\n";
typedef vector<int> vii;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int MOD = 1e9 + 7;
const int INF = 1e9;
int main()
{
   ll t;
   cin>>t;
   while(t--){
       ll n,m=1e9,cnt=0;
       cin>>n;
       ll a[n];
       rep(i,n) {cin>>a[i];m=min(m,a[i]);}
      // cout<<m<<endl;
       for(int i=0;i<n;i++){
           if(a[i]!=m){
               ll j=i;
               while(j+1<n && a[j]==a[j+1]) j++;
               i=j;
               cnt++;
           }
           
       }
       c(cnt)
   }
  
}

Generated URL:

Output:

4
0
Report Bug