Sunday, September 15, 2019

AtCoder Beginner Contest 136(C - Build Stairs)

  1. #include< bits/stdc++.h >
  2. using namespace std;
  3. int main()
  4. {
  5. int n, m;
  6. int vc[100001];
  7. cin >> n;
  8. for(int i = 0; i < n; i++){
  9. cin >> vc[i];
  10. }
  11. for(int i = n - 1; i > 0; i--) {
  12. if(vc[i] < vc[i-1]) vc[i - 1] -= 1;
  13. }
  14. for(int i = 1; i < n; i++) {
  15. if(vc[i-1] > vc[i]) return cout << "No" << endl, 0;
  16. }
  17. cout << "Yes" << endl;
  18. return 0;
  19. }

No comments: