fork download
  1. //#include<bits/stdc++.h>
  2. #include<iostream>
  3. #include<string>
  4. #include<iomanip>
  5. #include<cmath>
  6. #include<algorithm>
  7. using namespace std;
  8. //Do whatever you can ^^
  9. int max(int arr[], int n)
  10. {
  11. int max = arr[0];
  12. for (int i = 1; i < n; i++)
  13. {
  14. if (max < arr[i])
  15. max = arr[i];
  16. }
  17. return max;
  18. }
  19. int min(int arr[], int n)
  20. {
  21. int min = arr[0];
  22. for (int i = 1; i < n; i++)
  23. {
  24. if (min> arr[i])
  25. min = arr[i];
  26. }
  27. return min;
  28. }
  29. int main()
  30. {
  31. //cout << fixed << setprecision(9);
  32. //freopen("Files.in", "r", stdin);
  33. //freopen("Files.out", "w", stdout);
  34. std::ios_base::sync_with_stdio(NULL);
  35. cin.tie(NULL); cout.tie(NULL);
  36. int n;
  37. cin >> n;
  38. long long arr[1000000];
  39. for (int i = 0; i < n; i++)
  40. {
  41. cin >> arr[i];
  42. }
  43. for (int i = 0; i < n - 1; i++)
  44. {
  45. if (arr[i] == arr[i + 1])
  46. {
  47. arr[i] = 0;
  48. arr[i + 1] = 0;
  49. }
  50. }
  51. for (int i = 0; i < n; i++)
  52. {
  53. if (arr[i] != 0)
  54. {
  55. cout << "NO\n";
  56. return 0;
  57.  
  58.  
  59. }
  60.  
  61. }
  62. cout << "YES\n";
  63.  
  64. // system("pause");
  65. }
Success #stdin #stdout 0s 22928KB
stdin
Standard input is empty
stdout
YES