#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fr(m) for(int i = 0; i < m; i++)
#define fro(m) for(int i=1; i<m; i++)
#define _ "\n"
#define nll cout<<'\n'
#define ff first
#define ss second
#define inff (1<<30)
#define srt(m) sort(m.begin(),m.end())
#define srtr(m) sort(m.rbegin(),m.rend())
#define rev(m) reverse(m.begin(),m.end())
void solve() {
int n; cin >> n;
vector<int>v(n);
fr(n) {
cin >> v[i];
if(v[i ] == 0) {
cout <<"-1";
return;
}
}
ll cnt = 1;
ll cur = v[0];
fr(n){
if(v[i] != cur){
cur = v[i];
cnt++;
}
// cout << i << " "<<cnt;
// nll;
}
cout << cnt;
nll;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
// int t; cin >> t;
// while (t--)
solve();
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |