Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- $$$$$$$\ $$\ $$$$$$$\
- $$ __$$\ \__| $$ __$$\
- $$ | $$ | $$$$$$\ $$$$$$\ $$\ $$$$$$$\ $$ | $$ | $$$$$$\ $$$$$$\ $$$$$$$\ $$$$$$\
- $$$$$$$\ |$$ __$$\ $$ __$$\ $$ |$$ _____|$$$$$$$\ | \____$$\ $$ __$$\ $$ _____|\____$$\
- $$ __$$\ $$ / $$ |$$ | \__|$$ |\$$$$$$\ $$ __$$\ $$$$$$$ |$$ | \__|$$ / $$$$$$$ |
- $$ | $$ |$$ | $$ |$$ | $$ | \____$$\ $$ | $$ |$$ __$$ |$$ | $$ | $$ __$$ |
- $$$$$$$ |\$$$$$$ |$$ | $$ |$$$$$$$ |$$$$$$$ |\$$$$$$$ |$$ | \$$$$$$$\\$$$$$$$ |
- \_______/ \______/ \__| \__|\_______/ \_______/ \_______|\__| \_______|\_______|
- */
- #include <bits/stdc++.h>
- typedef long long ll;
- #define pb push_back
- #define mp make_pair
- #define pii pair <int,int>
- #define in insert
- #define X first
- #define Y second
- #define frn front
- #define bc back
- #define rep(i,a,b)for (ll (i) = (a); (i) < b(); ++(i))
- #define _ << " " <<
- #define sz(x) (int)x.size()
- #define all(a) (a).begin(),(a).end()
- using namespace std;
- int n, a;
- set <int> sol;
- vector <int> v;
- int main () {
- ios_base::sync_with_stdio(false);
- cin >>n;
- for (int i = 0; i < n; ++i){
- cin >>a;
- v.pb(a);
- }
- int curr = v[0];
- int cnt = 0;
- for (int i = 0; i < n; ++i){
- if (v[i] == curr){
- cnt++;
- continue;
- }
- else {
- if (curr == 0)
- curr = 1;
- else
- curr = 0;
- }
- sol.in(cnt);
- cnt = 1;
- }
- sol.in(cnt);
- if (sol.size() == 1)
- cout <<"YES\n";
- else
- cout <<"NO\n";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement