Advertisement
Guest User

Untitled

a guest
Mar 17th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.53 KB | None | 0 0
  1. /*
  2. $$$$$$$\ $$\ $$$$$$$\
  3. $$ __$$\ \__| $$ __$$\
  4. $$ | $$ | $$$$$$\ $$$$$$\ $$\ $$$$$$$\ $$ | $$ | $$$$$$\ $$$$$$\ $$$$$$$\ $$$$$$\
  5. $$$$$$$\ |$$ __$$\ $$ __$$\ $$ |$$ _____|$$$$$$$\ | \____$$\ $$ __$$\ $$ _____|\____$$\
  6. $$ __$$\ $$ / $$ |$$ | \__|$$ |\$$$$$$\ $$ __$$\ $$$$$$$ |$$ | \__|$$ / $$$$$$$ |
  7. $$ | $$ |$$ | $$ |$$ | $$ | \____$$\ $$ | $$ |$$ __$$ |$$ | $$ | $$ __$$ |
  8. $$$$$$$ |\$$$$$$ |$$ | $$ |$$$$$$$ |$$$$$$$ |\$$$$$$$ |$$ | \$$$$$$$\\$$$$$$$ |
  9. \_______/ \______/ \__| \__|\_______/ \_______/ \_______|\__| \_______|\_______|
  10. */
  11. #include <bits/stdc++.h>
  12.  
  13. typedef long long ll;
  14. #define pb push_back
  15. #define mp make_pair
  16. #define pii pair <int,int>
  17. #define in insert
  18. #define X first
  19. #define Y second
  20. #define frn front
  21. #define bc back
  22. #define rep(i,a,b)for (ll (i) = (a); (i) < b(); ++(i))
  23. #define _ << " " <<
  24. #define sz(x) (int)x.size()
  25. #define all(a) (a).begin(),(a).end()
  26.  
  27. using namespace std;
  28.  
  29. int n, a;
  30.  
  31. set <int> sol;
  32.  
  33. vector <int> v;
  34.  
  35. int main () {
  36. ios_base::sync_with_stdio(false);
  37. cin >>n;
  38. for (int i = 0; i < n; ++i){
  39. cin >>a;
  40. v.pb(a);
  41. }
  42. int curr = v[0];
  43. int cnt = 0;
  44. for (int i = 0; i < n; ++i){
  45. if (v[i] == curr){
  46. cnt++;
  47. continue;
  48. }
  49. else {
  50. if (curr == 0)
  51. curr = 1;
  52. else
  53. curr = 0;
  54. }
  55. sol.in(cnt);
  56. cnt = 1;
  57. }
  58. sol.in(cnt);
  59. if (sol.size() == 1)
  60. cout <<"YES\n";
  61. else
  62. cout <<"NO\n";
  63. return 0;
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement