-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSCTDL060.cpp
37 lines (35 loc) · 880 Bytes
/
SCTDL060.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/**
* @file SCTDL060.cpp
* @author long ([email protected])
* @brief Given an array only includes 0 & 1 elements.
* Count the number of '0' elements in array.
* '0' elements only are front of '1' elements.
* @version 0.1
* @date 2023-06-10
*
* @copyright Copyright (c) 2023
*
*/
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
int t;
cin >> t;
while (t--)
{
int n;
cin >> n;
int a[n];
for (int i = 0; i < n; i++)
cin >> a[i];
// using lower_bound() to find an iterator pointing to the first element
// in range [a, a+n] which has a value not less than 1.
// - a: return to index in array a by minus to a(beginning iterator).
int m = lower_bound(a, a + n, 1) - a;
cout << m << endl;
}
}