Thanos Sort
题意翻译
## 题目描述
[灭霸排序](https://codegolf.stackexchange.com/questions/182221/implement-the-thanos-sorting-algorithm)是一种超级反派排序算法。
它是这样运行的:
对于一个序列$a$,满足$\forall i<j,a_i\le a_j$,就停止排序;
否则删掉这个序列的左半边或右半边。
按此规则重复执行,直到满足上述条件。
现在给你一个序列,对其进行这种排序算法后,最大长度会是多少呢?
## 输入输出格式
### 输入格式
第一行一个正整数$n$
下面一行$n$个正整数$a_i$,表示序列$a$的第$i$项。
### 输出格式
输出一个正整数,表示排序后序列$a$的最大长度。
## 说明
### 数据范围:
$n\in\{1,2,4,8,16\}$
$1\le a_i\le 100$
题目描述
[Thanos sort](https://codegolf.stackexchange.com/questions/182221/implement-the-thanos-sorting-algorithm) is a supervillain sorting algorithm, which works as follows: if the array is not sorted, snap your fingers\* to remove the first or the second half of the items, and repeat the process.
Given an input array, what is the size of the longest sorted array you can obtain from it using Thanos sort?
\*Infinity Gauntlet required.
输入输出格式
输入格式
The first line of input contains a single number $ n $ ( $ 1 \le n \le 16 $ ) — the size of the array. $ n $ is guaranteed to be a power of 2.
The second line of input contains $ n $ space-separated integers $ a_i $ ( $ 1 \le a_i \le 100 $ ) — the elements of the array.
输出格式
Return the maximal length of a sorted array you can obtain using Thanos sort. The elements of the array have to be sorted in non-decreasing order.
输入输出样例
输入样例 #1
4
1 2 2 4
输出样例 #1
4
输入样例 #2
8
11 12 1 2 13 14 3 4
输出样例 #2
2
输入样例 #3
4
7 6 5 4
输出样例 #3
1
说明
In the first example the array is already sorted, so no finger snaps are required.
In the second example the array actually has a subarray of 4 sorted elements, but you can not remove elements from different sides of the array in one finger snap. Each time you have to remove either the whole first half or the whole second half, so you'll have to snap your fingers twice to get to a 2-element sorted array.
In the third example the array is sorted in decreasing order, so you can only save one element from the ultimate destruction.