fork download
  1. // R. Cell Borders
  2. #define DaAbyad ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  3. #include<bits/stdc++.h>
  4. using namespace std;
  5. const int N = 1e5 + 5, MOD = 1e9 + 7;
  6. const long long oo = 1e18 + 5;
  7. const long double pi = acos(-1);
  8. const long double eps = 1e-9;
  9. void open_file(string filename) {
  10. freopen((filename + ".in").c_str(), "r", stdin);
  11. freopen((filename + ".out").c_str(), "w", stdout);
  12. }
  13.  
  14. void Magic() {
  15. int n;
  16. cin >> n;
  17. int a[n];
  18. for (int i = 0; i < n; ++i) {
  19. cin >> a[i];
  20. }
  21. int l = 0, r = 1;
  22. bool flag1 = false, flag2 = false;
  23. for (int i = 0; i < n; ++i) {
  24. l = a[i] - l;
  25. r = a[i] - r;
  26. if (l < 0 || l > 1) {
  27. flag1 = true;
  28. }
  29. if (r < 0 || r > 1) {
  30. flag2 = true;
  31. }
  32. if (flag1 && flag2) {
  33. cout << "No\n";
  34. return;
  35. }
  36. }
  37. cout << "Yes\n";
  38. }
  39.  
  40. int main() {
  41. DaAbyad
  42. int tests = 1;
  43. // cin >> tests;
  44. while (tests--) {
  45. Magic();
  46. }
  47. return 0;
  48. }
Success #stdin #stdout 0s 5280KB
stdin
Standard input is empty
stdout
Yes