#include using namespace std;

int main() { int n; cin >> n;

int heights[n];
for (int i = 0; i < n; i++) {
    cin >> heights[i];
}

bool canJump = true;
int currentHeight = heights[0];
for (int i = 1; i < n; i++) {
    if (heights[i] > currentHeight) {
        canJump = false;
        break;
    }
    currentHeight = heights[i];
}

if (canJump) {
    cout << "yes" << endl;
} else {
    cout << "no" << endl;
}

return 0;

}

C++ 仅使用 iostream 库判断猫能否跳到最后一棵树 - 算法题

原文地址: http://www.cveoy.top/t/topic/p3LH 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录