Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int pyra(const int *array, int n) {
- if (n >= 3) {
- for (int i = 0; i < n / 2 - 1; i++) {
- if ((array[i] > array[2 * i + 1]) || (array[i] > array[2 * i + 2]))
- return 0;
- }
- }
- return 1;
- }
- int main() {
- freopen("isheap.in", "r", stdin);
- freopen("isheap.out", "w", stdout);
- char* answer[2] = {"NO", "YES"};
- int n;
- cin>>n;
- int* arr = new int[n];
- for(int i=0; i<n; i++){
- cin>>arr[i];
- }
- int result = pyra(arr, n);
- cout<<answer[result];
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement