A. Thanos Sort
time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

Thanos sort 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.

Input

The first line of input contains a single number nn (1≤n≤161≤n≤16) — the size of the array. nn is guaranteed to be a power of 2.

The second line of input contains nn space-separated integers aiai (1≤ai≤1001≤ai≤100) — the elements of the array.

Output

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.

Examples
input

Copy
4
1 2 2 4
output

Copy
4
input

Copy
8
11 12 1 2 13 14 3 4
output

Copy
2
input

Copy
4
7 6 5 4
output

Copy
1
Note

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 th

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.

思路:可以用递归先判断是不是排好了,如果没有,那么再看前半段或者后半段

返回最大值即可

#include<iostream>
using namespace std;
int a[];
int b[],c[],d[];
int ff(int x,int y){
int t=,sum=;
for(int i=x+;i<=y;i++){
if(a[i]>=a[i-])
sum++;
else{
t=;
}
}
if(t==)
return sum;
else
return max(ff(x,(x+y-)/),ff((x+y+)/,y));
}
int main(){
int n;
cin>>n;
for(int i=;i<=n;i++){
cin>>a[i];
}
cout<<ff(,n)<<endl;
return ;
}
B. Kanban Numbers
time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

 
Input

The input contains a single integer aa (1≤a≤991≤a≤99).

Output

Output "YES" or "NO".

Examples
input

 
5
output

 
YES
input

 
13
output

 
NO
input

 
24
output

 
NO
input

 
46
output

 
YES
这个就是脑洞题了,题目信息很少,kanban数就是把数字转化为英语,
然后含有k,n,a,b的为no
没有这些字母的是yes;真是脑洞大开
C. Mystery Circuit
time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

Input

The input contains a single integer aa (0≤a≤150≤a≤15).

Output

Output a single integer.

Example
input

 
3
output

 
13

April Fools Day Contest 2019: editorial回顾补题的更多相关文章

  1. April Fools Day Contest 2019 A. Thanos Sort

    A. Thanos Sort time limit per test 1 second memory limit per test 256 megabytes input standard input ...

  2. April Fools Day Contest 2014

    April Fools Day Contest 2014 A.C.H三道题目 ============================================================= ...

  3. 坑爹CF April Fools Day Contest题解

    H - A + B Strikes Back A + B is often used as an example of the easiest problem possible to show som ...

  4. April Fools Day Contest 2014 H. A + B Strikes Back

    H. A + B Strikes Back time limit per test 1 second memory limit per test 256 megabytes input standar ...

  5. April Fools Day Contest 2016 D. Rosetta Problem

    D. Rosetta Problem 题目连接: http://www.codeforces.com/contest/656/problem/D Description ++++++++[>+& ...

  6. April Fools Day Contest 2016 G. You're a Professional

    G. You're a Professional 题目连接: http://www.codeforces.com/contest/656/problem/G Description A simple ...

  7. April Fools Day Contest 2016 F. Ace It!

    F. Ace It! 题目连接: http://www.codeforces.com/contest/656/problem/F Description Input The only line of ...

  8. April Fools Day Contest 2016 E. Out of Controls

    E. Out of Controls 题目连接: http://www.codeforces.com/contest/656/problem/E Description You are given a ...

  9. April Fools Day Contest 2016 C. Without Text 信号与系统

    C. Without Text 题目连接: http://www.codeforces.com/contest/656/problem/C Description You can preview th ...

随机推荐

  1. windows 2003 server 64 位 IIS 6下部署 32位网站

    在 C:\WINDOWS\system32\inetsrv\MetaBase.xml 设置节点 在 开始--->运行--->输入一下代码,回车即可,就会跳出正在安装NET2.0 代码为   ...

  2. Java-Maven:Maven百科

    ylbtech-Java-Maven:Maven百科 1.返回顶部 1. Maven项目对象模型(POM),可以通过一小段描述信息来管理项目的构建,报告和文档的软件项目管理工具.Maven 除了以程序 ...

  3. org.springframework.web.struts.ContextLoaderPlugIn 和 org.springframework.web.context.ContextLoaderListener

    org.springframework.web.struts.ContextLoaderPlugIn 和 org.springframework.web.context.ContextLoaderLi ...

  4. 关于netty的多个handler链式模式

    1. 老规矩, 引入我们喜闻乐见的maven依赖 <dependency> <groupId>io.netty</groupId> <artifactId&g ...

  5. PCB Polar SI9000阻抗模型图片文字识别方法

    用过Polar SI9000的都知道,阻抗模型图片可以进行用户鼠标交互,那么它的是如何实现的呢,下面就讲一下如何实现此功能的方法   一.看看Polar SI9000阻抗模型图片交互效果 鼠标点击阻抗 ...

  6. E201700525-hm

    skeleton n. 骨骼; (建筑物等的) 骨架; 梗概; 骨瘦如柴的人(或动物);adj. 骨骼的; 骨瘦如柴的; 概略的; 基本的; cloud   n. 云; 云状物;  invoke   ...

  7. 洛谷 P3953 逛公园【spfa+记忆化dfs+bfs】

    spfa预处理出最短路数组dis,然后反向建边bfs出ok[u]表示u能到n点 然后发现有0环的话时候有inf解的,先dfs找0环判断即可 然后dfs,设状态f[u][v]为到u点,还可以跑最短路+v ...

  8. element中upload单图片转base64后添加进数组,请求接口

    //先上代码 <template> <!-- data绑定的参数 getuploadloge: [ { url: '', name: '' } ], --> <!-- 编 ...

  9. Luogu P1140 相似基因 【dp】By cellur925

    最近博客更不起来...然后又(照例)犯鼻炎了唉难受. 题目传送门 我们首先可以预处理碱基间的权值表.然后讲读入的碱基转化为数字,就变成了“数字匹配使权值最大”的问题.我们显然可以用动态规划解决. 两个 ...

  10. quickpow || 快速幂

    洛谷例题 推荐自行脑补:百度百科 如果  ,那么 : 前言:快速幂就是快速算底数的n次幂.其时间复杂度为 O(log₂N), 与朴素的O(N)相比效率有了极大的提高. 拿题目样例 Input :2 1 ...